Was this page helpful?
Caution
You're viewing documentation for an unstable version of ScyllaDB Node.js Driver. Switch to the latest stable version.
FrameWriter¶
FrameWriter()
Encodes values into values frames, in the request frame layout:
[u16 count], then for each value [i32 length][bytes].
Length -1 is null, and -2 is unset.
The writer reuses its buffer between frames. A frame is a view of that buffer, valid until the next frame of the same writer. Thus, pass a frame to Rust immediately. This is safe, because Rust copies the frame before the native call returns.
Callers must obey these rules. Otherwise, concurrent requests can send each other's values, with no error:
- Do not
awaitbetween writing a frame and passing it to Rust. Another request can write its own frame during theawait. - Do not keep a frame after the native call returns. Copy it if you need it later, for example in a test.
In the driver, only RustSession uses a writer.
Its structure enforces these rules. See its documentation.
A writer writes one frame at a time. A nested frame on the same writer throws, because it would overwrite the frame in progress.
Constructor¶
new FrameWriter()
Source
Methods¶
batch(expectedTypes, params, encoder)
Encodes the params of all statements of a batch into one frame:
[u16 statement count], then one params row per statement.
Parameters:
| Name | Type | Description |
|---|---|---|
expectedTypes |
List of expected types, one list per statement. |
|
params |
Params, one array per statement. |
|
encoder |
Source
Throws:
ArgumentError when there are more than 65,535 statements, or more than 65,535 params in one statement
Returns:
The frame, valid until the next frame of this writer.
buffers(values)
Writes values that are already encoded into one frame.
null is written as null, and undefined as unset.
Parameters:
| Name | Type | Description |
|---|---|---|
values |
Encoded values. |
Throws:
-
TypeError when a value is not a Uint8Array, null or undefined
-
ArgumentError when there are more than 65,535 values
Returns:
The frame, valid until the next frame of this writer.
params(expectedTypes, params, encoder)
Encodes all params of a statement into one frame.
Parameters:
| Name | Type | Description |
|---|---|---|
expectedTypes |
List of expected types. |
|
params |
||
encoder |
Source
Throws:
ArgumentError when there are more than 65,535 params
Returns:
The frame, valid until the next frame of this writer.