Struct write_into::Plain
source · [−]pub struct Plain<T>(pub T);
Expand description
Used to write values as they are represented in memory.
Examples
Writing struct into a sink.
use write_into::{Plain, write_into};
struct Rgba {
r: u8,
g: u8,
b: u8,
a: u8,
}
let color = Rgba { r: 0x18, g: 0x18, b: 0x18, a: 0xFF };
let mut buffer = Vec::new();
write_into(&mut buffer, Plain(&color)).unwrap();
assert_eq!(&buffer, &[0x18, 0x18, 0x18, 0xFF]);
Writing array into a sink.
use write_into::{Plain, write_into};
let bytes: &[u8; 4] = b"\0asm";
let mut buffer = Vec::new();
write_into(&mut buffer, Plain(bytes)).unwrap();
assert_eq!(&buffer, b"\0asm");
Writing slice into a sink (the crate also provides implementation for Plain<&str>
).
use write_into::{Plain, write_into};
let bytes: &[u8] = b"([Ljava/lang/String;)V";
let mut buffer = Vec::new();
write_into(&mut buffer, Plain(bytes)).unwrap();
assert_eq!(&buffer, b"([Ljava/lang/String;)V");
Tuple Fields
0: T
Trait Implementations
sourceimpl<T> WriteInto for Plain<&T>
impl<T> WriteInto for Plain<&T>
Transmutes arbitrary value into a byte slice.
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl<T> WriteInto for &Plain<&T>
impl<T> WriteInto for &Plain<&T>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<i128>
impl WriteInto for Plain<i128>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<isize>
impl WriteInto for Plain<isize>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<u8>
impl WriteInto for Plain<u8>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<u16>
impl WriteInto for Plain<u16>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<u32>
impl WriteInto for Plain<u32>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<u64>
impl WriteInto for Plain<u64>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<u128>
impl WriteInto for Plain<u128>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<usize>
impl WriteInto for Plain<usize>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<bool>
impl WriteInto for Plain<bool>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<char>
impl WriteInto for Plain<char>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl<T> WriteInto for Plain<&[T]>
impl<T> WriteInto for Plain<&[T]>
Transmutes arbitrary slice into a byte slice.
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<f32>
impl WriteInto for Plain<f32>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<f64>
impl WriteInto for Plain<f64>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl<T> WriteInto for &Plain<&[T]>
impl<T> WriteInto for &Plain<&[T]>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<&str>
impl WriteInto for Plain<&str>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for &Plain<&str>
impl WriteInto for &Plain<&str>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<i8>
impl WriteInto for Plain<i8>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
sourceimpl WriteInto for Plain<i16>
impl WriteInto for Plain<i16>
type Output = ()
type Output = ()
Result of WriteInto::write_into
function (e.g. ()
or usize
).
sourcefn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
fn write_into(self, sink: &mut impl Write) -> Result<Self::Output>
Writes value into I/O sink.
Auto Trait Implementations
impl<T> RefUnwindSafe for Plain<T> where
T: RefUnwindSafe,
impl<T> Send for Plain<T> where
T: Send,
impl<T> Sync for Plain<T> where
T: Sync,
impl<T> Unpin for Plain<T> where
T: Unpin,
impl<T> UnwindSafe for Plain<T> where
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more