pub struct CopyDataBuilder { /* private fields */ }Expand description
A builder for HyperBinary COPY data.
Provides a convenient interface for constructing HyperBinary COPY format data.
Automatically writes the header before the first data value.
§Example
use hyperdb_api_core::protocol::copy::CopyDataBuilder;
let mut builder = CopyDataBuilder::new(1024);
builder.write_i32(42, false);
builder.write_str("hello", false);
let data = builder.take();Implementations§
Source§impl CopyDataBuilder
impl CopyDataBuilder
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates a new builder with the specified initial capacity.
§Arguments
capacity- Initial buffer capacity in bytes
Sourcepub fn with_default_capacity() -> Self
pub fn with_default_capacity() -> Self
Creates a new builder with default capacity (1 MB).
Sourcepub fn ensure_header(&mut self)
pub fn ensure_header(&mut self)
Ensures the HyperBinary COPY header is written.
Called automatically before writing any data. Writes the header only once, even if called multiple times.
Sourcepub fn write_null(&mut self)
pub fn write_null(&mut self)
Writes a NULL value.
Sourcepub fn write_bool(&mut self, value: bool, nullable: bool)
pub fn write_bool(&mut self, value: bool, nullable: bool)
Writes a boolean value.
Sourcepub fn write_data128(&mut self, value: &[u8; 16], nullable: bool)
pub fn write_data128(&mut self, value: &[u8; 16], nullable: bool)
Writes a 128-bit value.
Sourcepub fn write_varbinary(&mut self, value: &[u8], nullable: bool)
pub fn write_varbinary(&mut self, value: &[u8], nullable: bool)
Writes a variable-length binary value (text, bytea, etc.).
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the current buffer size in bytes.
Includes the header if it has been written.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the buffer is empty (no data written yet).
Note: This returns true even if the header has been written, since the header is written automatically before data.
Sourcepub fn take(&mut self) -> BytesMut
pub fn take(&mut self) -> BytesMut
Returns the buffer contents and resets the builder.
The builder can be reused after calling this method. The header flag is reset, so the header will be written again on the next write operation.
Trait Implementations§
Source§impl Debug for CopyDataBuilder
impl Debug for CopyDataBuilder
Auto Trait Implementations§
impl Freeze for CopyDataBuilder
impl RefUnwindSafe for CopyDataBuilder
impl Send for CopyDataBuilder
impl Sync for CopyDataBuilder
impl Unpin for CopyDataBuilder
impl UnsafeUnpin for CopyDataBuilder
impl UnwindSafe for CopyDataBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request