Trait concordium_std::Write

source ·
pub trait Write {
    type Err: Default;

    // Required method
    fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Err>;

    // Provided methods
    fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Err> { ... }
    fn write_u8(&mut self, x: u8) -> Result<(), Self::Err> { ... }
    fn write_u16(&mut self, x: u16) -> Result<(), Self::Err> { ... }
    fn write_u32(&mut self, x: u32) -> Result<(), Self::Err> { ... }
    fn write_u64(&mut self, x: u64) -> Result<(), Self::Err> { ... }
    fn write_i8(&mut self, x: i8) -> Result<(), Self::Err> { ... }
    fn write_i16(&mut self, x: i16) -> Result<(), Self::Err> { ... }
    fn write_i32(&mut self, x: i32) -> Result<(), Self::Err> { ... }
    fn write_i64(&mut self, x: i64) -> Result<(), Self::Err> { ... }
}
Expand description

The Write trait provides functionality for writing to byte streams.

Required Associated Types§

Required Methods§

source

fn write(&mut self, buf: &[u8]) -> Result<usize, Self::Err>

Try to write the given buffer into the output stream. If writes are successful returns the number of bytes written.

Provided Methods§

source

fn write_all(&mut self, buf: &[u8]) -> Result<(), Self::Err>

Attempt to write the entirety of the buffer to the output by repeatedly calling write until either no more output can written, or writing fails.

source

fn write_u8(&mut self, x: u8) -> Result<(), Self::Err>

Write a single byte to the output.

source

fn write_u16(&mut self, x: u16) -> Result<(), Self::Err>

Write a u16 in little endian.

source

fn write_u32(&mut self, x: u32) -> Result<(), Self::Err>

Write a u32 in little endian.

source

fn write_u64(&mut self, x: u64) -> Result<(), Self::Err>

Write a u64 in little endian.

source

fn write_i8(&mut self, x: i8) -> Result<(), Self::Err>

Write a i8 to the output.

source

fn write_i16(&mut self, x: i16) -> Result<(), Self::Err>

Write a i16 in little endian.

source

fn write_i32(&mut self, x: i32) -> Result<(), Self::Err>

Write a i32 in little endian.

source

fn write_i64(&mut self, x: i64) -> Result<(), Self::Err>

Write a i64 in little endian.

Implementations on Foreign Types§

source§

impl Write for &mut [u8]

This implementation overwrite the contents of the slice and updates the reference to point to the unwritten part. The slice is (by necessity) never extended. This is in contrast to the Vec<u8> implementation which always extends the vector with the data that is written.

§

type Err = ()

source§

fn write(&mut self, buf: &[u8]) -> Result<usize, <&mut [u8] as Write>::Err>

Implementors§

source§

impl Write for Cursor<&mut Vec<u8, Global>>

§

type Err = ()

source§

impl Write for ExternReturnValue

Return values are intended to be produced by writing to the ExternReturnValue buffer, either in a high-level interface via serialization, or in a low-level interface by manually using the Write trait’s interface.

§

type Err = ()

source§

impl Write for StateEntry

§

type Err = ()

source§

impl Write for Vec<u8, Global>

The write method always appends data to the end of the vector.

§

type Err = ()

source§

impl Write for TestStateEntry