Skip to main content

Writer

Trait Writer 

Source
pub trait Writer {
    type Error: Error;

    // Required method
    fn write_bytes(&mut self, bytes: &[u8]) -> Result<(), Self::Error>;

    // Provided methods
    fn write_byte(&mut self, b: u8) -> Result<(), Self::Error> { ... }
    fn write_array<const N: usize>(
        &mut self,
        array: [u8; N],
    ) -> Result<(), Self::Error> { ... }
}
Expand description

The trait governing how a writer works.

Required Associated Types§

Source

type Error: Error

The error type raised by the writer.

Required Methods§

Source

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

Write bytes to the current writer.

Provided Methods§

Source

fn write_byte(&mut self, b: u8) -> Result<(), Self::Error>

Write a single byte.

Source

fn write_array<const N: usize>( &mut self, array: [u8; N], ) -> Result<(), Self::Error>

Write an array to the current writer.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Writer for Vec<u8>

Available on crate feature std only.
Source§

type Error = VecWriterError

Source§

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

Source§

fn write_byte(&mut self, b: u8) -> Result<(), Self::Error>

Source§

fn write_array<const N: usize>( &mut self, array: [u8; N], ) -> Result<(), Self::Error>

Source§

impl<W> Writer for &mut W
where W: ?Sized + Writer,

Source§

type Error = <W as Writer>::Error

Source§

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

Source§

fn write_byte(&mut self, b: u8) -> Result<(), Self::Error>

Source§

fn write_array<const N: usize>( &mut self, array: [u8; N], ) -> Result<(), Self::Error>

Implementors§

Source§

impl<W> Writer for Wrap<W>
where W: Write,

Available on crate feature std only.
Source§

impl<const N: usize, E> Writer for FixedBytes<N, E>
where E: Error,

Source§

type Error = E