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§
Auto Trait Implementations§
impl<T> Freeze for Plain<T>where
T: Freeze,
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§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more