pub trait GenericDataSink: DataSink {
// Provided methods
fn write_int<T: Pod + PrimInt>(&mut self, value: T) -> Result { ... }
fn write_int_le<T: Pod + PrimInt>(&mut self, value: T) -> Result { ... }
fn write_data<T: Pod>(&mut self, value: T) -> Result { ... }
}Expand description
Writes generic data to a sink.
Provided Methods§
Sourcefn write_int<T: Pod + PrimInt>(&mut self, value: T) -> Result
fn write_int<T: Pod + PrimInt>(&mut self, value: T) -> Result
Writes a big-endian integer.
§Errors
May return Overflow if the sink would exceed some hard
storage limit. In the case, the stream is filled completely, excluding the
overflowing bytes.
§Example
use data_streams::GenericDataSink;
let mut buf = Vec::new();
buf.write_int(0x12345678)?;
assert_eq!(buf, [0x12, 0x34, 0x56, 0x78]);Sourcefn write_int_le<T: Pod + PrimInt>(&mut self, value: T) -> Result
fn write_int_le<T: Pod + PrimInt>(&mut self, value: T) -> Result
Writes a little-endian integer.
§Errors
May return Overflow if the sink would exceed some hard
storage limit. In the case, the stream is filled completely, excluding the
overflowing bytes.
§Example
use data_streams::GenericDataSink;
let mut buf = Vec::new();
buf.write_int_le(0x12345678)?;
assert_eq!(buf, [0x78, 0x56, 0x34, 0x12]);Sourcefn write_data<T: Pod>(&mut self, value: T) -> Result
fn write_data<T: Pod>(&mut self, value: T) -> Result
Writes a value of an arbitrary bit pattern. See Pod.
§Errors
May return Overflow if the sink would exceed some hard
storage limit. In the case, the stream is filled completely, excluding the
overflowing bytes.
§Example
use data_streams::GenericDataSink;
let mut buf = Vec::new();
buf.write_data(0x12345678)?;
assert_eq!(buf, [0x78, 0x56, 0x34, 0x12]);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.