Crates.io | write-into |
lib.rs | write-into |
version | 0.3.10 |
source | src |
created_at | 2022-05-21 22:08:36.479537 |
updated_at | 2022-10-31 19:07:38.900783 |
description | A trait to write things into io::Write. |
homepage | |
repository | https://github.com/abvalatouski/write-into |
max_upload_size | |
id | 590897 |
size | 27,031 |
write-into
Defines a trait built on top of io::Write
to write things into it.
use std::io;
trait WriteInto {
type Output;
fn write_into(self, sink: &mut impl io::Write) -> io::Result<Self::Output>;
}
The crate also provides wrappers, such as BigEndian
and LittleEndian
, to write values
in particular formats.
use write_into::{BigEndian, write_into};
let mut buffer = Vec::new();
write_into(&mut buffer, BigEndian(0xCAFEBABEu32)).unwrap();
assert_eq!(&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. |
Sequence |
... from IntoIterator . |
Sized |
... prepended with size of their representation. |
SizedSequence |
... from IntoIterator with known size. |
Sleb128 |
... in LEB-128 format (signed). |
Uleb128 |
... in LEB-128 format (unsigned). |