Struct grin_core::ser::BinWriter

source ·
pub struct BinWriter<'a> { /* private fields */ }
Expand description

Utility wrapper for an underlying byte Writer. Defines higher level methods to write numbers, byte vectors, hashes, etc.

Implementations§

source§

impl<'a> BinWriter<'a>

source

pub fn new(sink: &'a mut dyn Write, version: ProtocolVersion) -> BinWriter<'a>

Wraps a standard Write in a new BinWriter

source

pub fn default(sink: &'a mut dyn Write) -> BinWriter<'a>

Constructor for BinWriter with default “local” protocol version.

Trait Implementations§

source§

impl<'a> Writer for BinWriter<'a>

source§

fn serialization_mode(&self) -> SerializationMode

The mode this serializer is writing in
source§

fn write_fixed_bytes<T: AsRef<[u8]>>(&mut self, bytes: T) -> Result<(), Error>

Writes a fixed number of bytes. The reader is expected to know the actual length on read.
source§

fn protocol_version(&self) -> ProtocolVersion

Protocol version for version specific serialization rules.
source§

fn write_u8(&mut self, n: u8) -> Result<(), Error>

Writes a u8 as bytes
source§

fn write_u16(&mut self, n: u16) -> Result<(), Error>

Writes a u16 as bytes
source§

fn write_u32(&mut self, n: u32) -> Result<(), Error>

Writes a u32 as bytes
source§

fn write_i32(&mut self, n: i32) -> Result<(), Error>

Writes a u32 as bytes
source§

fn write_u64(&mut self, n: u64) -> Result<(), Error>

Writes a u64 as bytes
source§

fn write_i64(&mut self, n: i64) -> Result<(), Error>

Writes a i64 as bytes
source§

fn write_bytes<T: AsRef<[u8]>>(&mut self, bytes: T) -> Result<(), Error>

Writes a variable number of bytes. The length is encoded as a 64-bit prefix.
source§

fn write_empty_bytes(&mut self, length: usize) -> Result<(), Error>

Writes a fixed length of “empty” bytes.

Auto Trait Implementations§

§

impl<'a> Freeze for BinWriter<'a>

§

impl<'a> !RefUnwindSafe for BinWriter<'a>

§

impl<'a> !Send for BinWriter<'a>

§

impl<'a> !Sync for BinWriter<'a>

§

impl<'a> Unpin for BinWriter<'a>

§

impl<'a> !UnwindSafe for BinWriter<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnsafeAny for T
where T: Any,