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