Was this page helpful?
RustSession¶
RustSession()
The native session of the driver.
Rust gives the session to JS as an External, not as an instance of a native class.
A method call on an instance of a native class costs napi_unwrap and a borrow check
of napi-rs. JS uses the session in each execution, so this cost adds up.
This class gives the session the same methods that the native class had.
Each method calls one Rust function with the External.
This class also owns the values frames of the session. Its methods take the values, encode them into a frame, and pass the frame to Rust. A frame is a view of one shared FrameWriter buffer, and the next frame overwrites it. Thus, these rules keep concurrent requests from sending each other's values:
- A frame never leaves this class. Callers cannot keep one across an
await. - Each method that writes a frame is not
async. Thus,awaitbetween writing the frame and the native call is a compile error. Do not make these methodsasync. - Rust copies the frame before the native call returns.
Constructor¶
new RustSession()
Source
Members¶
inner
The native session, for the Rust functions that take it as an argument.
Source
Methods¶
batch(types, params)
Parameters:
| Name | Type | Description |
|---|---|---|
types |
The expected types, one list for each statement. |
|
params |
The values, one array for each statement. |
batchPrepared(types, params)
Parameters:
| Name | Type | Description |
|---|---|---|
types |
The expected types, one list for each statement. |
|
params |
The values, one array for each statement. |
computeToken(components)
Parameters:
| Name | Type | Description |
|---|---|---|
components |
The partition key values, already encoded.
|
(async, static) create(encoder)
Creates a session based on the provided session options.
Parameters:
| Name | Type | Description |
|---|---|---|
encoder |
Encodes the values of the requests of this session. |
Source