pub struct ByteBlockWriter { /* private fields */ }
Expand description
The byte block writer.
All writes (write_type
and write
) will be buffered in the internal
buffer of the ByteBlockWriter using the specified encoding.
To finalize all the writes, invoke finish
to obtain the encoded byte
block.
Implementations§
source§impl ByteBlockWriter
impl ByteBlockWriter
sourcepub fn new(encoding: AccountBlockFormat) -> Self
pub fn new(encoding: AccountBlockFormat) -> Self
Create a ByteBlockWriter from the specified AccountBlockFormat.
sourcepub fn write_pod<T: NoUninit>(&mut self, value: &T) -> IoResult<usize>
pub fn write_pod<T: NoUninit>(&mut self, value: &T) -> IoResult<usize>
Write plain ol’ data to the internal buffer of the ByteBlockWriter instance
Prefer this over write_type()
, as it prevents some undefined behavior.
sourcepub unsafe fn write_type<T>(&mut self, value: &T) -> IoResult<usize>
pub unsafe fn write_type<T>(&mut self, value: &T) -> IoResult<usize>
Write the specified typed instance to the internal buffer of the ByteBlockWriter instance.
Prefer write_pod()
when possible, because write_type()
may cause
undefined behavior if value
contains uninitialized bytes.
§Safety
Caller must ensure casting T to bytes is safe. Refer to the Safety sections in std::slice::from_raw_parts() and bytemuck’s Pod and NoUninit for more information.
sourcepub fn write_optional_fields(
&mut self,
opt_fields: &AccountMetaOptionalFields,
) -> IoResult<usize>
pub fn write_optional_fields( &mut self, opt_fields: &AccountMetaOptionalFields, ) -> IoResult<usize>
Write all the Some fields of the specified AccountMetaOptionalFields.
Note that the existence of each optional field is stored separately in AccountMetaFlags.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ByteBlockWriter
impl RefUnwindSafe for ByteBlockWriter
impl Send for ByteBlockWriter
impl !Sync for ByteBlockWriter
impl Unpin for ByteBlockWriter
impl UnwindSafe for ByteBlockWriter
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more