write-into
Defines a trait built on top of io::Write
to write things into it.
```rust use std::io;
trait WriteInto {
type Output;
fn write_into(self, sink: &mut impl io::Write) -> io::Result
The crate also provides wrappers, such as BigEndian
and LittleEndian
, to write values
in particular formats.
```rust use writeinto::{BigEndian, writeinto};
let mut buffer = Vec::new(); writeinto(&mut buffer, BigEndian(0xCAFEBABEu32)).unwrap(); asserteq!(&buffer, &[0xCA, 0xFE, 0xBA, 0xBE]); ```
| Wrapper | Used to write values... |
| -------------- | -------------------------------------- |
| BigEndian
| ... in big endian byte order. |
| LittleEndian
| ... in little endian byte order. |
| Plain
| ... as they are represented in memory. |
| Sleb128
| ... in LEB-128 format (signed). |
| Uleb128
| ... in LEB-128 format (unsigned). |