Trait object::write::WritableBuffer
source · pub trait WritableBuffer {
// Required methods
fn len(&self) -> usize;
fn reserve(&mut self, size: usize) -> Result<(), ()>;
fn resize(&mut self, new_len: usize);
fn write_bytes(&mut self, val: &[u8]);
// Provided methods
fn write_pod<T: Pod>(&mut self, val: &T)
where Self: Sized { ... }
fn write_pod_slice<T: Pod>(&mut self, val: &[T])
where Self: Sized { ... }
}
Expand description
Trait for writable buffer.
Required Methods§
sourcefn len(&self) -> usize
fn len(&self) -> usize
Returns position/offset for data to be written at.
Should only be used in debug assertions
sourcefn reserve(&mut self, size: usize) -> Result<(), ()>
fn reserve(&mut self, size: usize) -> Result<(), ()>
Reserves specified number of bytes in the buffer.
This will be called exactly once before writing anything to the buffer, and the given size is the exact total number of bytes that will be written.
sourcefn resize(&mut self, new_len: usize)
fn resize(&mut self, new_len: usize)
Writes zero bytes at the end of the buffer until the buffer has the specified length.
sourcefn write_bytes(&mut self, val: &[u8])
fn write_bytes(&mut self, val: &[u8])
Writes the specified slice of bytes at the end of the buffer.
Provided Methods§
sourcefn write_pod<T: Pod>(&mut self, val: &T)where
Self: Sized,
fn write_pod<T: Pod>(&mut self, val: &T)where
Self: Sized,
Writes the specified Pod
type at the end of the buffer.
sourcefn write_pod_slice<T: Pod>(&mut self, val: &[T])where
Self: Sized,
fn write_pod_slice<T: Pod>(&mut self, val: &[T])where
Self: Sized,
Writes the specified Pod
slice at the end of the buffer.