pub trait Writable<'a>{
Show 141 methods
// Required methods
fn as_trait(&mut self) -> &mut dyn Writable<'a>;
fn alloc(&mut self, len: u64) -> Result<()>;
fn lock(&mut self, block: bool) -> Result<()>;
fn unlock(&mut self) -> Result<()>;
fn close(self) -> Result<Option<DataType<'a>>>;
// Provided methods
fn limit(&'a mut self, pos: u64, length: u64) -> Result<WLimited<'a>> { ... }
fn write_bytes_at(&mut self, pos: u64, buf: &[u8]) -> Result<()> { ... }
fn write_utf8_at(&mut self, pos: u64, s: &String) -> Result<()> { ... }
fn write_u8_at(&mut self, pos: u64, num: u8) -> Result<()> { ... }
fn write_u16le_at(&mut self, pos: u64, num: u16) -> Result<()> { ... }
fn write_u16be_at(&mut self, pos: u64, num: u16) -> Result<()> { ... }
fn write_u32le_at(&mut self, pos: u64, num: u32) -> Result<()> { ... }
fn write_u32be_at(&mut self, pos: u64, num: u32) -> Result<()> { ... }
fn write_u64le_at(&mut self, pos: u64, num: u64) -> Result<()> { ... }
fn write_u64be_at(&mut self, pos: u64, num: u64) -> Result<()> { ... }
fn write_u128le_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_u128be_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu7_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu7r_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu15le_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu15be_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu15ler_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu15ber_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu31le_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu31be_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu31ler_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu31ber_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu63le_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu63be_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu63ler_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu63ber_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu127le_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu127be_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu127ler_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_vu127ber_at(&mut self, pos: u64, num: u128) -> Result<()> { ... }
fn write_uxle_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()> { ... }
fn write_uxbe_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxle_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxbe_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxler_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxber_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()> { ... }
fn write_i8_at(&mut self, pos: u64, num: i8) -> Result<()> { ... }
fn write_i16le_at(&mut self, pos: u64, num: i16) -> Result<()> { ... }
fn write_i16be_at(&mut self, pos: u64, num: i16) -> Result<()> { ... }
fn write_i32le_at(&mut self, pos: u64, num: i32) -> Result<()> { ... }
fn write_i32be_at(&mut self, pos: u64, num: i32) -> Result<()> { ... }
fn write_i64le_at(&mut self, pos: u64, num: i64) -> Result<()> { ... }
fn write_i64be_at(&mut self, pos: u64, num: i64) -> Result<()> { ... }
fn write_i128le_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_i128be_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi7_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi7r_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi15le_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi15be_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi15ler_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi15ber_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi31le_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi31be_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi31ler_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi31ber_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi63le_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi63be_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi63ler_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi127le_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi127be_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi127ler_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_vi127ber_at(&mut self, pos: u64, num: i128) -> Result<()> { ... }
fn write_ixle_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()> { ... }
fn write_ixbe_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()> { ... }
fn write_vixle_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()> { ... }
fn write_vixbe_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()> { ... }
fn write_vixler_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()> { ... }
fn write_vixber_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()> { ... }
fn write_bytes(&mut self, vec: &[u8]) -> Result<()> { ... }
fn write_utf8(&mut self, s: &String) -> Result<()> { ... }
fn write_u8(&mut self, num: u8) -> Result<()> { ... }
fn write_u16le(&mut self, num: u16) -> Result<()> { ... }
fn write_u16be(&mut self, num: u16) -> Result<()> { ... }
fn write_u32le(&mut self, num: u32) -> Result<()> { ... }
fn write_u32be(&mut self, num: u32) -> Result<()> { ... }
fn write_u64le(&mut self, num: u64) -> Result<()> { ... }
fn write_u64be(&mut self, num: u64) -> Result<()> { ... }
fn write_u128le(&mut self, num: u128) -> Result<()> { ... }
fn write_u128be(&mut self, num: u128) -> Result<()> { ... }
fn write_vu7(&mut self, num: u128) -> Result<()> { ... }
fn write_vu7r(&mut self, num: u128) -> Result<()> { ... }
fn write_vu15le(&mut self, num: u128) -> Result<()> { ... }
fn write_vu15be(&mut self, num: u128) -> Result<()> { ... }
fn write_vu15ler(&mut self, num: u128) -> Result<()> { ... }
fn write_vu15ber(&mut self, num: u128) -> Result<()> { ... }
fn write_vu31le(&mut self, num: u128) -> Result<()> { ... }
fn write_vu31be(&mut self, num: u128) -> Result<()> { ... }
fn write_vu31ler(&mut self, num: u128) -> Result<()> { ... }
fn write_vu31ber(&mut self, num: u128) -> Result<()> { ... }
fn write_vu63le(&mut self, num: u128) -> Result<()> { ... }
fn write_vu63be(&mut self, num: u128) -> Result<()> { ... }
fn write_vu63ler(&mut self, num: u128) -> Result<()> { ... }
fn write_vu63ber(&mut self, num: u128) -> Result<()> { ... }
fn write_vu127le(&mut self, num: u128) -> Result<()> { ... }
fn write_vu127be(&mut self, num: u128) -> Result<()> { ... }
fn write_vu127ler(&mut self, num: u128) -> Result<()> { ... }
fn write_vu127ber(&mut self, num: u128) -> Result<()> { ... }
fn write_uxle(&mut self, size: u8, num: u128) -> Result<()> { ... }
fn write_uxbe(&mut self, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxle(&mut self, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxbe(&mut self, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxler(&mut self, size: u8, num: u128) -> Result<()> { ... }
fn write_vuxber(&mut self, size: u8, num: u128) -> Result<()> { ... }
fn write_i8(&mut self, num: i8) -> Result<()> { ... }
fn write_i16le(&mut self, num: i16) -> Result<()> { ... }
fn write_i16be(&mut self, num: i16) -> Result<()> { ... }
fn write_i32le(&mut self, num: i32) -> Result<()> { ... }
fn write_i32be(&mut self, num: i32) -> Result<()> { ... }
fn write_i64le(&mut self, num: i64) -> Result<()> { ... }
fn write_i64be(&mut self, num: i64) -> Result<()> { ... }
fn write_i128le(&mut self, num: i128) -> Result<()> { ... }
fn write_i128be(&mut self, num: i128) -> Result<()> { ... }
fn write_vi7(&mut self, num: i128) -> Result<()> { ... }
fn write_vi7r(&mut self, num: i128) -> Result<()> { ... }
fn write_vi15le(&mut self, num: i128) -> Result<()> { ... }
fn write_vi15be(&mut self, num: i128) -> Result<()> { ... }
fn write_vi15ler(&mut self, num: i128) -> Result<()> { ... }
fn write_vi15ber(&mut self, num: i128) -> Result<()> { ... }
fn write_vi31le(&mut self, num: i128) -> Result<()> { ... }
fn write_vi31be(&mut self, num: i128) -> Result<()> { ... }
fn write_vi31ler(&mut self, num: i128) -> Result<()> { ... }
fn write_vi31ber(&mut self, num: i128) -> Result<()> { ... }
fn write_vi63le(&mut self, num: i128) -> Result<()> { ... }
fn write_vi63be(&mut self, num: i128) -> Result<()> { ... }
fn write_vi63ler(&mut self, num: i128) -> Result<()> { ... }
fn write_vi63ber(&mut self, num: i128) -> Result<()> { ... }
fn write_vi127le(&mut self, num: i128) -> Result<()> { ... }
fn write_vi127be(&mut self, num: i128) -> Result<()> { ... }
fn write_vi127ler(&mut self, num: i128) -> Result<()> { ... }
fn write_vi127ber(&mut self, num: i128) -> Result<()> { ... }
fn write_ixle(&mut self, size: u8, num: i128) -> Result<()> { ... }
fn write_ixbe(&mut self, size: u8, num: i128) -> Result<()> { ... }
fn write_vixle(&mut self, size: u8, num: i128) -> Result<()> { ... }
fn write_vixbe(&mut self, size: u8, num: i128) -> Result<()> { ... }
fn write_vixler(&mut self, size: u8, num: i128) -> Result<()> { ... }
fn write_vixber(&mut self, size: u8, num: i128) -> Result<()> { ... }
}Expand description
Provides methods to write data to a target.
Although the trait can be implemented for any type that implements Write and Seekable,
for most cases the internal implementations are recommended.
Required Methods§
sourcefn alloc(&mut self, len: u64) -> Result<()>
fn alloc(&mut self, len: u64) -> Result<()>
Pre-allocates space in the data stream. This is useful when you know the size of the data you are going to write and want to avoid reallocations for performance reasons. Also, you can guarantee that the data will fit in the stream.
§Example
use dh::recommended::*;
let mut file = dh::file::open_w("doctest-writable-alloc").unwrap();
let str = "Hello, world!".to_string();
file.alloc(str.len() as u64).unwrap();
file.write_utf8(&str).unwrap(); // this needs no reallocationsourcefn lock(&mut self, block: bool) -> Result<()>
fn lock(&mut self, block: bool) -> Result<()>
Locks the source exclusively for the current process. This only has an effect on some sources, like files.
§Example
use dh::recommended::*;
let mut file1 = dh::file::open_w("doctest-writable-lock").unwrap();
file1.lock(true).unwrap(); // this would block the thread until the file is unlocked
let mut file2 = dh::file::open_w("doctest-writable-lock").unwrap();
file2.lock(false).unwrap(); // fails, because the file is already lockedsourcefn unlock(&mut self) -> Result<()>
fn unlock(&mut self) -> Result<()>
Unlocks the source for other processes. This happens automatically when the source goes out of scope, is closed or dropped.
§Example
use dh::recommended::*;
let mut file = dh::file::open_w("tests/samples/000").unwrap();
file.lock(true).unwrap();
// do something with the file
file.unlock().unwrap();sourcefn close(self) -> Result<Option<DataType<'a>>>
fn close(self) -> Result<Option<DataType<'a>>>
Closes the reader and can return the source if it was moved or references it.
§Example
use dh::recommended::*;
let mut reader = dh::data::write(vec![]);
// do something with the writer
reader.close().unwrap(); // if the writer goes out of scope, this happens automaticallyProvided Methods§
sourcefn limit(&'a mut self, pos: u64, length: u64) -> Result<WLimited<'a>>
fn limit(&'a mut self, pos: u64, length: u64) -> Result<WLimited<'a>>
Limits the space the writer can write to.
The writer will only be able to write from pos to pos + length.
Note: The writer will automatically jump to the start of the limit here.
§Example
use dh::recommended::*;
let mut writer = dh::data::write(vec![0, 1, 2, 3, 4, 5, 6, 7]);
let mut limited = writer.limit(2, 4).unwrap();
let size = limited.size().unwrap();
limited.write_bytes(&vec![5, 4, 3, 2]).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0, 1, 5, 4, 3, 2, 6, 7]);sourcefn write_bytes_at(&mut self, pos: u64, buf: &[u8]) -> Result<()>
fn write_bytes_at(&mut self, pos: u64, buf: &[u8]) -> Result<()>
Writes bytes at a specific position.
This executes the write_bytes method at pos and then returns to the original position.
sourcefn write_utf8_at(&mut self, pos: u64, s: &String) -> Result<()>
fn write_utf8_at(&mut self, pos: u64, s: &String) -> Result<()>
Writes an UTF-8-encoded string at a specific position.
This executes the write_utf8 method at pos and then returns to the original position.
sourcefn write_u8_at(&mut self, pos: u64, num: u8) -> Result<()>
fn write_u8_at(&mut self, pos: u64, num: u8) -> Result<()>
Writes an unsigned 8-bit integer at a specific position.
This executes the write_u8 method at pos and then returns to the original position.
sourcefn write_u16le_at(&mut self, pos: u64, num: u16) -> Result<()>
fn write_u16le_at(&mut self, pos: u64, num: u16) -> Result<()>
Writes an unsigned 16-bit integer in little-endian byte order at a specific position.
This executes the write_u16le method at pos and then returns to the original position.
sourcefn write_u16be_at(&mut self, pos: u64, num: u16) -> Result<()>
fn write_u16be_at(&mut self, pos: u64, num: u16) -> Result<()>
Writes an unsigned 16-bit integer in big-endian byte order at a specific position.
This executes the write_u16be method at pos and then returns to the original position.
sourcefn write_u32le_at(&mut self, pos: u64, num: u32) -> Result<()>
fn write_u32le_at(&mut self, pos: u64, num: u32) -> Result<()>
Writes an unsigned 32-bit integer in little-endian byte order at a specific position.
This executes the write_u32le method at pos and then returns to the original position.
sourcefn write_u32be_at(&mut self, pos: u64, num: u32) -> Result<()>
fn write_u32be_at(&mut self, pos: u64, num: u32) -> Result<()>
Writes an unsigned 32-bit integer in big-endian byte order at a specific position.
This executes the write_u32be method at pos and then returns to the original position.
sourcefn write_u64le_at(&mut self, pos: u64, num: u64) -> Result<()>
fn write_u64le_at(&mut self, pos: u64, num: u64) -> Result<()>
Writes an unsigned 64-bit integer in little-endian byte order at a specific position.
This executes the write_u64le method at pos and then returns to the original position.
sourcefn write_u64be_at(&mut self, pos: u64, num: u64) -> Result<()>
fn write_u64be_at(&mut self, pos: u64, num: u64) -> Result<()>
Writes an unsigned 64-bit integer in big-endian byte order at a specific position.
This executes the write_u64be method at pos and then returns to the original position.
sourcefn write_u128le_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_u128le_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 128-bit integer in little-endian byte order at a specific position.
This executes the write_u128le method at pos and then returns to the original position.
sourcefn write_u128be_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_u128be_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 128-bit integer in big-endian byte order at a specific position.
This executes the write_u128be method at pos and then returns to the original position.
sourcefn write_vu7_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu7_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 7-bit variable-length integer at a specific position.
This executes the write_vu7 method at pos and then returns to the original position.
sourcefn write_vu7r_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu7r_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 7-bit variable-length integer in reversed byte order at a specific position.
This executes the write_vu7r method at pos and then returns to the original position.
sourcefn write_vu15le_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu15le_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vu15le method at pos and then returns to the original position.
sourcefn write_vu15be_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu15be_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vu15be method at pos and then returns to the original position.
sourcefn write_vu15ler_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu15ler_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vu15ler method at pos and then returns to the original position.
sourcefn write_vu15ber_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu15ber_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vu15ber method at pos and then returns to the original position.
sourcefn write_vu31le_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu31le_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vu31le method at pos and then returns to the original position.
sourcefn write_vu31be_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu31be_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vu31be method at pos and then returns to the original position.
sourcefn write_vu31ler_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu31ler_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vu31ler method at pos and then returns to the original position.
sourcefn write_vu31ber_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu31ber_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vu31ber method at pos and then returns to the original position.
sourcefn write_vu63le_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu63le_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vu63le method at pos and then returns to the original position.
sourcefn write_vu63be_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu63be_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vu63be method at pos and then returns to the original position.
sourcefn write_vu63ler_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu63ler_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vu63ler method at pos and then returns to the original position.
sourcefn write_vu63ber_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu63ber_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vu63ber method at pos and then returns to the original position.
sourcefn write_vu127le_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu127le_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vu127le method at pos and then returns to the original position.
sourcefn write_vu127be_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu127be_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vu127be method at pos and then returns to the original position.
sourcefn write_vu127ler_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu127ler_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vu127ler method at pos and then returns to the original position.
sourcefn write_vu127ber_at(&mut self, pos: u64, num: u128) -> Result<()>
fn write_vu127ber_at(&mut self, pos: u64, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vu127ber method at pos and then returns to the original position.
sourcefn write_uxle_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
fn write_uxle_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
Writes an unsigned integer in little-endian byte order at a specific position.
This executes the write_uxle method at pos and then returns to the original position.
sourcefn write_uxbe_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
fn write_uxbe_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
Writes an unsigned integer in big-endian byte order at a specific position.
This executes the write_uxbe method at pos and then returns to the original position.
sourcefn write_vuxle_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
fn write_vuxle_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in little-endian byte order at a specific position.
This executes the write_vuxle method at pos and then returns to the original position.
sourcefn write_vuxbe_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
fn write_vuxbe_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vuxler method at pos and then returns to the original position.
sourcefn write_vuxler_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
fn write_vuxler_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vuxler method at pos and then returns to the original position.
sourcefn write_vuxber_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
fn write_vuxber_at(&mut self, pos: u64, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vuxber method at pos and then returns to the original position.
sourcefn write_i8_at(&mut self, pos: u64, num: i8) -> Result<()>
fn write_i8_at(&mut self, pos: u64, num: i8) -> Result<()>
Writes a signed 8-bit integer at a specific position.
This executes the write_i8 method at pos and then returns to the original position.
sourcefn write_i16le_at(&mut self, pos: u64, num: i16) -> Result<()>
fn write_i16le_at(&mut self, pos: u64, num: i16) -> Result<()>
Writes a signed 16-bit integer in little-endian byte order at a specific position.
This executes the write_i16le method at pos and then returns to the original position.
sourcefn write_i16be_at(&mut self, pos: u64, num: i16) -> Result<()>
fn write_i16be_at(&mut self, pos: u64, num: i16) -> Result<()>
Writes a signed 16-bit integer in big-endian byte order at a specific position.
This executes the write_i16be method at pos and then returns to the original position.
sourcefn write_i32le_at(&mut self, pos: u64, num: i32) -> Result<()>
fn write_i32le_at(&mut self, pos: u64, num: i32) -> Result<()>
Writes a signed 32-bit integer in little-endian byte order at a specific position.
This executes the write_i32le method at pos and then returns to the original position.
sourcefn write_i32be_at(&mut self, pos: u64, num: i32) -> Result<()>
fn write_i32be_at(&mut self, pos: u64, num: i32) -> Result<()>
Writes a signed 32-bit integer in big-endian byte order at a specific position.
This executes the write_i32be method at pos and then returns to the original position.
sourcefn write_i64le_at(&mut self, pos: u64, num: i64) -> Result<()>
fn write_i64le_at(&mut self, pos: u64, num: i64) -> Result<()>
Writes a signed 64-bit integer in little-endian byte order at a specific position.
This executes the write_i64le method at pos and then returns to the original position.
sourcefn write_i64be_at(&mut self, pos: u64, num: i64) -> Result<()>
fn write_i64be_at(&mut self, pos: u64, num: i64) -> Result<()>
Writes a signed 64-bit integer in big-endian byte order at a specific position.
This executes the write_i64be method at pos and then returns to the original position.
sourcefn write_i128le_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_i128le_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 128-bit integer in little-endian byte order at a specific position.
This executes the write_i128le method at pos and then returns to the original position.
sourcefn write_i128be_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_i128be_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 128-bit integer in big-endian byte order at a specific position.
This executes the write_i128be method at pos and then returns to the original position.
sourcefn write_vi7_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi7_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 7-bit variable-length integer at a specific position.
This executes the write_vi7 method at pos and then returns to the original position.
sourcefn write_vi7r_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi7r_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 7-bit variable-length integer in reversed byte order at a specific position.
This executes the write_vi7r method at pos and then returns to the original position.
sourcefn write_vi15le_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi15le_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vi15le method at pos and then returns to the original position.
sourcefn write_vi15be_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi15be_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vi15be method at pos and then returns to the original position.
sourcefn write_vi15ler_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi15ler_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vi15ler method at pos and then returns to the original position.
sourcefn write_vi15ber_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi15ber_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vi15ber method at pos and then returns to the original position.
sourcefn write_vi31le_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi31le_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vi31le method at pos and then returns to the original position.
sourcefn write_vi31be_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi31be_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vi31be method at pos and then returns to the original position.
sourcefn write_vi31ler_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi31ler_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vi31ler method at pos and then returns to the original position.
sourcefn write_vi31ber_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi31ber_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vi31ber method at pos and then returns to the original position.
sourcefn write_vi63le_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi63le_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vi63le method at pos and then returns to the original position.
sourcefn write_vi63be_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi63be_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vi63be method at pos and then returns to the original position.
sourcefn write_vi63ler_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi63ler_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vi63ler method at pos and then returns to the original position.
sourcefn write_vi127le_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi127le_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in little-endian byte order at a specific position.
This executes the write_vi127le method at pos and then returns to the original position.
sourcefn write_vi127be_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi127be_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in big-endian byte order at a specific position.
This executes the write_vi127be method at pos and then returns to the original position.
sourcefn write_vi127ler_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi127ler_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vi127ler method at pos and then returns to the original position.
sourcefn write_vi127ber_at(&mut self, pos: u64, num: i128) -> Result<()>
fn write_vi127ber_at(&mut self, pos: u64, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vi127ber method at pos and then returns to the original position.
sourcefn write_ixle_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
fn write_ixle_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
Writes a signed integer in little-endian byte order at a specific position.
This executes the write_ixle method at pos and then returns to the original position.
sourcefn write_ixbe_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
fn write_ixbe_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
Writes a signed integer in big-endian byte order at a specific position.
This executes the write_ixbe method at pos and then returns to the original position.
sourcefn write_vixle_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
fn write_vixle_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in little-endian byte order at a specific position.
This executes the write_vixle method at pos and then returns to the original position.
sourcefn write_vixbe_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
fn write_vixbe_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in big-endian byte order at a specific position.
This executes the write_vixbe method at pos and then returns to the original position.
sourcefn write_vixler_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
fn write_vixler_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in reversed little-endian byte order at a specific position.
This executes the write_vixler method at pos and then returns to the original position.
sourcefn write_vixber_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
fn write_vixber_at(&mut self, pos: u64, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in reversed big-endian byte order at a specific position.
This executes the write_vixber method at pos and then returns to the original position.
sourcefn write_bytes(&mut self, vec: &[u8]) -> Result<()>
fn write_bytes(&mut self, vec: &[u8]) -> Result<()>
Writes bytes at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(5);
writer.write_bytes(&[1, 2, 3, 4, 5]).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![1, 2, 3, 4, 5]);sourcefn write_utf8(&mut self, s: &String) -> Result<()>
fn write_utf8(&mut self, s: &String) -> Result<()>
Writes an UTF-8-encoded string at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(5);
writer.write_utf8(&"Hello".to_string()).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x48, 0x65, 0x6c, 0x6c, 0x6f]);sourcefn write_u8(&mut self, num: u8) -> Result<()>
fn write_u8(&mut self, num: u8) -> Result<()>
Writes an unsigned 8-bit integer at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(1);
writer.write_u8(0x48).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x48]);sourcefn write_u16le(&mut self, num: u16) -> Result<()>
fn write_u16le(&mut self, num: u16) -> Result<()>
Writes an unsigned 16-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(2);
writer.write_u16le(0x02_01).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02]);sourcefn write_u16be(&mut self, num: u16) -> Result<()>
fn write_u16be(&mut self, num: u16) -> Result<()>
Writes an unsigned 16-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(2);
writer.write_u16be(0x01_02).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02]);sourcefn write_u32le(&mut self, num: u32) -> Result<()>
fn write_u32le(&mut self, num: u32) -> Result<()>
Writes an unsigned 32-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(4);
writer.write_u32le(0x04_03_02_01).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03, 0x04]);sourcefn write_u32be(&mut self, num: u32) -> Result<()>
fn write_u32be(&mut self, num: u32) -> Result<()>
Writes an unsigned 32-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(4);
writer.write_u32be(0x01_02_03_04).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03, 0x04]);sourcefn write_u64le(&mut self, num: u64) -> Result<()>
fn write_u64le(&mut self, num: u64) -> Result<()>
Writes an unsigned 64-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(8);
writer.write_u64le(0x08_07_06_05_04_03_02_01).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]);sourcefn write_u64be(&mut self, num: u64) -> Result<()>
fn write_u64be(&mut self, num: u64) -> Result<()>
Writes an unsigned 64-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(8);
writer.write_u64be(0x01_02_03_04_05_06_07_08).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]);sourcefn write_u128le(&mut self, num: u128) -> Result<()>
fn write_u128le(&mut self, num: u128) -> Result<()>
Writes an unsigned 128-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(16);
writer.write_u128le(0x10_0f_0e_0d_0c_0b_0a_09_08_07_06_05_04_03_02_01).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10]);sourcefn write_u128be(&mut self, num: u128) -> Result<()>
fn write_u128be(&mut self, num: u128) -> Result<()>
Writes an unsigned 128-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(16);
writer.write_u128be(0x01_02_03_04_05_06_07_08_09_0a_0b_0c_0d_0e_0f_10).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10]);sourcefn write_vu7(&mut self, num: u128) -> Result<()>
fn write_vu7(&mut self, num: u128) -> Result<()>
Writes an unsigned 7-bit variable-length integer at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu7(0xff).unwrap();
rw.rewind();
assert_eq!(rw.read_vu7().unwrap(), 0xff);sourcefn write_vu7r(&mut self, num: u128) -> Result<()>
fn write_vu7r(&mut self, num: u128) -> Result<()>
Writes an unsigned 7-bit variable-length integer in reversed byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu7r(0xff).unwrap();
rw.rewind();
assert_eq!(rw.read_vu7r().unwrap(), 0xff);sourcefn write_vu15le(&mut self, num: u128) -> Result<()>
fn write_vu15le(&mut self, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu15le(0xff_ee).unwrap();
rw.rewind();
assert_eq!(rw.read_vu15le().unwrap(), 0xff_ee);sourcefn write_vu15be(&mut self, num: u128) -> Result<()>
fn write_vu15be(&mut self, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu15be(0xff_ee).unwrap();
rw.rewind();
assert_eq!(rw.read_vu15be().unwrap(), 0xff_ee);sourcefn write_vu15ler(&mut self, num: u128) -> Result<()>
fn write_vu15ler(&mut self, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in reversed little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu15ler(0xff_ee).unwrap();
rw.rewind();
assert_eq!(rw.read_vu15ler().unwrap(), 0xff_ee);sourcefn write_vu15ber(&mut self, num: u128) -> Result<()>
fn write_vu15ber(&mut self, num: u128) -> Result<()>
Writes an unsigned 15-bit variable-length integer in reversed big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu15ber(0xff_ee).unwrap();
rw.rewind();
assert_eq!(rw.read_vu15ber().unwrap(), 0xff_ee);sourcefn write_vu31le(&mut self, num: u128) -> Result<()>
fn write_vu31le(&mut self, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu31le(0xff_ee_dd_cc).unwrap();
rw.rewind();
assert_eq!(rw.read_vu31le().unwrap(), 0xff_ee_dd_cc);sourcefn write_vu31be(&mut self, num: u128) -> Result<()>
fn write_vu31be(&mut self, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu31be(0xff_ee_dd_cc).unwrap();
rw.rewind();
assert_eq!(rw.read_vu31be().unwrap(), 0xff_ee_dd_cc);sourcefn write_vu31ler(&mut self, num: u128) -> Result<()>
fn write_vu31ler(&mut self, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in reversed little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu31ler(0xff_ee_dd_cc).unwrap();
rw.rewind();
assert_eq!(rw.read_vu31ler().unwrap(), 0xff_ee_dd_cc);sourcefn write_vu31ber(&mut self, num: u128) -> Result<()>
fn write_vu31ber(&mut self, num: u128) -> Result<()>
Writes an unsigned 31-bit variable-length integer in reversed big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu31ber(0xff_ee_dd_cc).unwrap();
rw.rewind();
assert_eq!(rw.read_vu31ber().unwrap(), 0xff_ee_dd_cc);sourcefn write_vu63le(&mut self, num: u128) -> Result<()>
fn write_vu63le(&mut self, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu63le(0xff_ee_dd_cc_bb_aa_99_88).unwrap();
rw.rewind();
assert_eq!(rw.read_vu63le().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88);sourcefn write_vu63be(&mut self, num: u128) -> Result<()>
fn write_vu63be(&mut self, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu63be(0xff_ee_dd_cc_bb_aa_99_88).unwrap();
rw.rewind();
assert_eq!(rw.read_vu63be().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88);sourcefn write_vu63ler(&mut self, num: u128) -> Result<()>
fn write_vu63ler(&mut self, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in reversed little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu63ler(0xff_ee_dd_cc_bb_aa_99_88).unwrap();
rw.rewind();
assert_eq!(rw.read_vu63ler().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88);sourcefn write_vu63ber(&mut self, num: u128) -> Result<()>
fn write_vu63ber(&mut self, num: u128) -> Result<()>
Writes an unsigned 63-bit variable-length integer in reversed big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu63ber(0xff_ee_dd_cc_bb_aa_99_88).unwrap();
rw.rewind();
assert_eq!(rw.read_vu63ber().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88);sourcefn write_vu127le(&mut self, num: u128) -> Result<()>
fn write_vu127le(&mut self, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu127le(0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00).unwrap();
rw.rewind();
assert_eq!(rw.read_vu127le().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00);sourcefn write_vu127be(&mut self, num: u128) -> Result<()>
fn write_vu127be(&mut self, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu127be(0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00).unwrap();
rw.rewind();
assert_eq!(rw.read_vu127be().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00);sourcefn write_vu127ler(&mut self, num: u128) -> Result<()>
fn write_vu127ler(&mut self, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in reversed little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu127ler(0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00).unwrap();
rw.rewind();
assert_eq!(rw.read_vu127ler().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00);sourcefn write_vu127ber(&mut self, num: u128) -> Result<()>
fn write_vu127ber(&mut self, num: u128) -> Result<()>
Writes an unsigned 127-bit variable-length integer in reversed big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vu127ber(0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00).unwrap();
rw.rewind();
assert_eq!(rw.read_vu127ber().unwrap(), 0xff_ee_dd_cc_bb_aa_99_88_77_66_55_44_33_22_11_00);sourcefn write_uxle(&mut self, size: u8, num: u128) -> Result<()>
fn write_uxle(&mut self, size: u8, num: u128) -> Result<()>
Writes an unsigned integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(3);
writer.write_uxle(3, 0x01_02_03).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x03, 0x02, 0x01]);sourcefn write_uxbe(&mut self, size: u8, num: u128) -> Result<()>
fn write_uxbe(&mut self, size: u8, num: u128) -> Result<()>
Writes an unsigned integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(3);
writer.write_uxbe(3, 0x01_02_03).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0x01, 0x02, 0x03]);sourcefn write_vuxle(&mut self, size: u8, num: u128) -> Result<()>
fn write_vuxle(&mut self, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vuxle(3, 0xff_ee_dd).unwrap();
rw.rewind();
assert_eq!(rw.read_vuxle(3).unwrap(), 0xff_ee_dd);sourcefn write_vuxbe(&mut self, size: u8, num: u128) -> Result<()>
fn write_vuxbe(&mut self, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vuxbe(3, 0xff_ee_dd).unwrap();
rw.rewind();
assert_eq!(rw.read_vuxbe(3).unwrap(), 0xff_ee_dd);sourcefn write_vuxler(&mut self, size: u8, num: u128) -> Result<()>
fn write_vuxler(&mut self, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in reversed little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vuxler(3, 0xff_ee_dd).unwrap();
rw.rewind();
assert_eq!(rw.read_vuxler(3).unwrap(), 0xff_ee_dd);sourcefn write_vuxber(&mut self, size: u8, num: u128) -> Result<()>
fn write_vuxber(&mut self, size: u8, num: u128) -> Result<()>
Writes an unsigned variable-length integer in reversed big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vuxber(3, 0xff_ee_dd).unwrap();
rw.rewind();
assert_eq!(rw.read_vuxber(3).unwrap(), 0xff_ee_dd);sourcefn write_i8(&mut self, num: i8) -> Result<()>
fn write_i8(&mut self, num: i8) -> Result<()>
Writes a signed 8-bit integer at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(1);
writer.write_i8(i8::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i8::MIN.to_le_bytes().to_vec());sourcefn write_i16le(&mut self, num: i16) -> Result<()>
fn write_i16le(&mut self, num: i16) -> Result<()>
Writes a signed 16-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(2);
writer.write_i16le(i16::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i16::MIN.to_le_bytes().to_vec());sourcefn write_i16be(&mut self, num: i16) -> Result<()>
fn write_i16be(&mut self, num: i16) -> Result<()>
Writes a signed 16-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(2);
writer.write_i16be(i16::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i16::MIN.to_be_bytes().to_vec());sourcefn write_i32le(&mut self, num: i32) -> Result<()>
fn write_i32le(&mut self, num: i32) -> Result<()>
Writes a signed 32-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(4);
writer.write_i32le(i32::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i32::MIN.to_le_bytes().to_vec());sourcefn write_i32be(&mut self, num: i32) -> Result<()>
fn write_i32be(&mut self, num: i32) -> Result<()>
Writes a signed 32-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(4);
writer.write_i32be(i32::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i32::MIN.to_be_bytes().to_vec());sourcefn write_i64le(&mut self, num: i64) -> Result<()>
fn write_i64le(&mut self, num: i64) -> Result<()>
Writes a signed 64-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(8);
writer.write_i64le(i64::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i64::MIN.to_le_bytes().to_vec());sourcefn write_i64be(&mut self, num: i64) -> Result<()>
fn write_i64be(&mut self, num: i64) -> Result<()>
Writes a signed 64-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(8);
writer.write_i64be(i64::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i64::MIN.to_be_bytes().to_vec());sourcefn write_i128le(&mut self, num: i128) -> Result<()>
fn write_i128le(&mut self, num: i128) -> Result<()>
Writes a signed 128-bit integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(16);
writer.write_i128le(i128::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i128::MIN.to_le_bytes().to_vec());sourcefn write_i128be(&mut self, num: i128) -> Result<()>
fn write_i128be(&mut self, num: i128) -> Result<()>
Writes a signed 128-bit integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(16);
writer.write_i128be(i128::MIN).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, i128::MIN.to_be_bytes().to_vec());sourcefn write_vi7(&mut self, num: i128) -> Result<()>
fn write_vi7(&mut self, num: i128) -> Result<()>
Writes a signed 7-bit variable-length integer at the current position.
This works like write_vu7 but for signed integers.
sourcefn write_vi7r(&mut self, num: i128) -> Result<()>
fn write_vi7r(&mut self, num: i128) -> Result<()>
Writes a signed 7-bit variable-length integer in reversed byte order at the current position.
This works like write_vu7r but for signed integers.
sourcefn write_vi15le(&mut self, num: i128) -> Result<()>
fn write_vi15le(&mut self, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in little-endian byte order at the current position.
This works like write_vu15le but for signed integers.
sourcefn write_vi15be(&mut self, num: i128) -> Result<()>
fn write_vi15be(&mut self, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in big-endian byte order at the current position.
This works like write_vu15be but for signed integers.
sourcefn write_vi15ler(&mut self, num: i128) -> Result<()>
fn write_vi15ler(&mut self, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in reversed little-endian byte order at the current position.
This works like write_vu15ler but for signed integers.
sourcefn write_vi15ber(&mut self, num: i128) -> Result<()>
fn write_vi15ber(&mut self, num: i128) -> Result<()>
Writes a signed 15-bit variable-length integer in reversed big-endian byte order at the current position.
This works like write_vu15ber but for signed integers.
sourcefn write_vi31le(&mut self, num: i128) -> Result<()>
fn write_vi31le(&mut self, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in little-endian byte order at the current position.
This works like write_vu31le but for signed integers.
sourcefn write_vi31be(&mut self, num: i128) -> Result<()>
fn write_vi31be(&mut self, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in big-endian byte order at the current position.
This works like write_vu31be but for signed integers.
sourcefn write_vi31ler(&mut self, num: i128) -> Result<()>
fn write_vi31ler(&mut self, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in reversed little-endian byte order at the current position.
This works like write_vu31ler but for signed integers.
sourcefn write_vi31ber(&mut self, num: i128) -> Result<()>
fn write_vi31ber(&mut self, num: i128) -> Result<()>
Writes a signed 31-bit variable-length integer in reversed big-endian byte order at the current position.
This works like write_vu31ber but for signed integers.
sourcefn write_vi63le(&mut self, num: i128) -> Result<()>
fn write_vi63le(&mut self, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in little-endian byte order at the current position.
This works like write_vu63le but for signed integers.
sourcefn write_vi63be(&mut self, num: i128) -> Result<()>
fn write_vi63be(&mut self, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in big-endian byte order at the current position.
This works like write_vu63be but for signed integers.
sourcefn write_vi63ler(&mut self, num: i128) -> Result<()>
fn write_vi63ler(&mut self, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in reversed little-endian byte order at the current position.
This works like write_vu63ler but for signed integers.
sourcefn write_vi63ber(&mut self, num: i128) -> Result<()>
fn write_vi63ber(&mut self, num: i128) -> Result<()>
Writes a signed 63-bit variable-length integer in reversed big-endian byte order at the current position.
This works like write_vu63ber but for signed integers.
sourcefn write_vi127le(&mut self, num: i128) -> Result<()>
fn write_vi127le(&mut self, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in little-endian byte order at the current position.
This works like write_vu127le but for signed integers.
sourcefn write_vi127be(&mut self, num: i128) -> Result<()>
fn write_vi127be(&mut self, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in big-endian byte order at the current position.
This works like write_vu127be but for signed integers.
sourcefn write_vi127ler(&mut self, num: i128) -> Result<()>
fn write_vi127ler(&mut self, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in reversed little-endian byte order at the current position.
This works like write_vu127ler but for signed integers.
sourcefn write_vi127ber(&mut self, num: i128) -> Result<()>
fn write_vi127ber(&mut self, num: i128) -> Result<()>
Writes a signed 127-bit variable-length integer in reversed big-endian byte order at the current position.
This works like write_vu127ber but for signed integers.
sourcefn write_ixle(&mut self, size: u8, num: i128) -> Result<()>
fn write_ixle(&mut self, size: u8, num: i128) -> Result<()>
Writes a signed integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(3);
writer.write_ixle(3, -0x01_02_03).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0xfd, 0xfd, 0xfe]);sourcefn write_ixbe(&mut self, size: u8, num: i128) -> Result<()>
fn write_ixbe(&mut self, size: u8, num: i128) -> Result<()>
Writes a signed integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut writer = dh::data::write_new(3);
writer.write_ixbe(3, -0x01_02_03).unwrap();
let data = dh::data::close(writer);
assert_eq!(data, vec![0xfe, 0xfd, 0xfd]);sourcefn write_vixle(&mut self, size: u8, num: i128) -> Result<()>
fn write_vixle(&mut self, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vixle(3, -0x01_02_03).unwrap();
rw.rewind();
assert_eq!(rw.read_vixle(3).unwrap(), -0x01_02_03);sourcefn write_vixbe(&mut self, size: u8, num: i128) -> Result<()>
fn write_vixbe(&mut self, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vixbe(3, -0x01_02_03).unwrap();
rw.rewind();
assert_eq!(rw.read_vixbe(3).unwrap(), -0x01_02_03);sourcefn write_vixler(&mut self, size: u8, num: i128) -> Result<()>
fn write_vixler(&mut self, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in reversed little-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vixler(3, -0x01_02_03).unwrap();
rw.rewind();
assert_eq!(rw.read_vixler(3).unwrap(), -0x01_02_03);sourcefn write_vixber(&mut self, size: u8, num: i128) -> Result<()>
fn write_vixber(&mut self, size: u8, num: i128) -> Result<()>
Writes a signed variable-length integer in reversed big-endian byte order at the current position.
§Example
use dh::recommended::*;
let mut rw = dh::data::rw_empty();
rw.write_vixber(3, -0x01_02_03).unwrap();
rw.rewind();
assert_eq!(rw.read_vixber(3).unwrap(), -0x01_02_03);