pub struct BufferWriter { /* private fields */ }Expand description
Write buffer with alignment tracking and configurable endianness.
Phase 0 uses Vec<u8> as backing — a growing alloc feature.
Implementations§
Source§impl BufferWriter
impl BufferWriter
Sourcepub fn new(endianness: Endianness) -> Self
pub fn new(endianness: Endianness) -> Self
Creates an empty writer with the given endianness (XCDR1 alignment, cap 8 — default + backward-compat).
Sourcepub fn with_capacity(endianness: Endianness, cap: usize) -> Self
pub fn with_capacity(endianness: Endianness, cap: usize) -> Self
Creates a writer with pre-allocated capacity (XCDR1 cap 8).
Sourcepub fn with_align_origin(self, origin: usize) -> Self
pub fn with_align_origin(self, origin: usize) -> Self
Builder: sets the virtual Self::align origin (default 0).
For GIOP 1.2 = 12 (header size), see the align_origin field doc.
Sourcepub fn with_max_alignment(self, max_alignment: usize) -> Self
pub fn with_max_alignment(self, max_alignment: usize) -> Self
Builder: sets the alignment cap (XCDR1=8, XCDR2=4). Inherited by
nested member writers (see struct_enc).
Sourcepub fn max_alignment(&self) -> usize
pub fn max_alignment(&self) -> usize
The current alignment cap (8 = XCDR1, 4 = XCDR2).
Sourcepub fn endianness(&self) -> Endianness
pub fn endianness(&self) -> Endianness
Returns the current endianness.
Sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Consumes the writer and returns the written buffer.
Sourcepub fn align(&mut self, alignment: usize)
pub fn align(&mut self, alignment: usize)
Inserts null padding until the current position is a multiple
of alignment. Alignment must be a power of two
(1, 2, 4, 8); other values are undefined in XCDR.
Sourcepub fn write_bytes(&mut self, data: &[u8]) -> Result<(), EncodeError>
pub fn write_bytes(&mut self, data: &[u8]) -> Result<(), EncodeError>
Writes raw bytes without alignment.
§Errors
Never returns an error with Vec-based backing — the signature
is symmetric to the slice-based writer (Phase 1).
Sourcepub fn write_string(&mut self, s: &str) -> Result<(), EncodeError>
pub fn write_string(&mut self, s: &str) -> Result<(), EncodeError>
Writes a CDR string (§9.3.2.7): 4-byte length (incl. null terminator) + UTF-8 bytes + 1 null byte. No trailing padding — the next field aligns itself.
§Errors
As write_bytes.
Trait Implementations§
Source§impl Clone for BufferWriter
impl Clone for BufferWriter
Source§fn clone(&self) -> BufferWriter
fn clone(&self) -> BufferWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more