Struct savefile::Serializer
source · [−]pub struct Serializer<'a> {
pub version: u32,
/* private fields */
}Expand description
Object to which serialized data is to be written.
This is basically just a wrapped std::io::Write object
and a file protocol version number.
Fields
version: u32The version of the data structures in memory which are being serialized.
Implementations
sourceimpl<'a> Serializer<'a>
impl<'a> Serializer<'a>
sourcepub fn write_bool(&mut self, v: bool) -> Result<(), SavefileError>
pub fn write_bool(&mut self, v: bool) -> Result<(), SavefileError>
Writes a binary bool to the dyn Write
sourcepub fn write_u8(&mut self, v: u8) -> Result<(), SavefileError>
pub fn write_u8(&mut self, v: u8) -> Result<(), SavefileError>
Writes a binary u8 to the dyn Write
sourcepub fn write_i8(&mut self, v: i8) -> Result<(), SavefileError>
pub fn write_i8(&mut self, v: i8) -> Result<(), SavefileError>
Writes a binary i8 to the dyn Write
sourcepub fn write_u16(&mut self, v: u16) -> Result<(), SavefileError>
pub fn write_u16(&mut self, v: u16) -> Result<(), SavefileError>
Writes a binary little endian u16 to the dyn Write
sourcepub fn write_i16(&mut self, v: i16) -> Result<(), SavefileError>
pub fn write_i16(&mut self, v: i16) -> Result<(), SavefileError>
Writes a binary little endian i16 to the dyn Write
sourcepub fn write_u32(&mut self, v: u32) -> Result<(), SavefileError>
pub fn write_u32(&mut self, v: u32) -> Result<(), SavefileError>
Writes a binary little endian u32 to the dyn Write
sourcepub fn write_i32(&mut self, v: i32) -> Result<(), SavefileError>
pub fn write_i32(&mut self, v: i32) -> Result<(), SavefileError>
Writes a binary little endian i32 to the dyn Write
sourcepub fn write_f32(&mut self, v: f32) -> Result<(), SavefileError>
pub fn write_f32(&mut self, v: f32) -> Result<(), SavefileError>
Writes a binary little endian f32 to the dyn Write
sourcepub fn write_f64(&mut self, v: f64) -> Result<(), SavefileError>
pub fn write_f64(&mut self, v: f64) -> Result<(), SavefileError>
Writes a binary little endian f64 to the dyn Write
sourcepub fn write_u64(&mut self, v: u64) -> Result<(), SavefileError>
pub fn write_u64(&mut self, v: u64) -> Result<(), SavefileError>
Writes a binary little endian u64 to the dyn Write
sourcepub fn write_i64(&mut self, v: i64) -> Result<(), SavefileError>
pub fn write_i64(&mut self, v: i64) -> Result<(), SavefileError>
Writes a binary little endian i64 to the dyn Write
sourcepub fn write_usize(&mut self, v: usize) -> Result<(), SavefileError>
pub fn write_usize(&mut self, v: usize) -> Result<(), SavefileError>
Writes a binary little endian usize as u64 to the dyn Write
sourcepub fn write_isize(&mut self, v: isize) -> Result<(), SavefileError>
pub fn write_isize(&mut self, v: isize) -> Result<(), SavefileError>
Writes a binary little endian isize as i64 to the dyn Write
sourcepub fn write_buf(&mut self, v: &[u8]) -> Result<(), SavefileError>
pub fn write_buf(&mut self, v: &[u8]) -> Result<(), SavefileError>
Writes a binary u8 array to the dyn Write
sourcepub fn write_string(&mut self, v: &str) -> Result<(), SavefileError>
pub fn write_string(&mut self, v: &str) -> Result<(), SavefileError>
Writes as a string as 64 bit length + utf8 data
sourcepub fn write_bytes(&mut self, v: &[u8]) -> Result<(), SavefileError>
pub fn write_bytes(&mut self, v: &[u8]) -> Result<(), SavefileError>
Writes a binary u8 array to the dyn Write. Synonym of write_buf.
sourcepub fn save<T: WithSchema + Serialize>(
writer: &mut dyn Write,
version: u32,
data: &T,
with_compression: bool
) -> Result<(), SavefileError>
pub fn save<T: WithSchema + Serialize>(
writer: &mut dyn Write,
version: u32,
data: &T,
with_compression: bool
) -> Result<(), SavefileError>
Creata a new serializer. Don’t use this function directly, use the crate::save function instead.
sourcepub fn save_noschema<T: WithSchema + Serialize>(
writer: &mut dyn Write,
version: u32,
data: &T
) -> Result<(), SavefileError>
pub fn save_noschema<T: WithSchema + Serialize>(
writer: &mut dyn Write,
version: u32,
data: &T
) -> Result<(), SavefileError>
Creata a new serializer. Don’t use this function directly, use the crate::save_noschema function instead.
sourcepub fn new_raw(writer: &mut dyn Write) -> Serializer<'_>
pub fn new_raw(writer: &mut dyn Write) -> Serializer<'_>
Create a Serializer. Don’t use this method directly, use the crate::save function instead.
Auto Trait Implementations
impl<'a> !RefUnwindSafe for Serializer<'a>
impl<'a> !Send for Serializer<'a>
impl<'a> !Sync for Serializer<'a>
impl<'a> Unpin for Serializer<'a>
impl<'a> !UnwindSafe for Serializer<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more