Encoder

Struct Encoder 

Source
#[non_exhaustive]
pub struct Encoder<'a, T> { pub stream: T, pub ctxt: Context<'a>, pub stack: Stack, }
Expand description

The base type for encoding/decoding. Wraps a stream, and a Context.
It’s recommended to wrap the stream in a std::io::BufReader or std::io::BufWriter, because many small write and read calls will be made.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§stream: T

The underlying stream

§ctxt: Context<'a>

The state

§stack: Stack
Available on crate feature debug only.

The stack

Implementations§

Source§

impl<'a, T> Encoder<'a, T>

Source

pub fn new(stream: T, ctxt: Context<'a>) -> Self

Wraps the given stream and state.

Source

pub fn swap_stream(&mut self, new: T) -> T

Replaces the underlying stream with the new one, returning the previous value

Source

pub fn user_data<U: Any>(&self) -> EncodingResult<&U>

Retrieves the user data and attempts to cast it to the given concrete type, returning a validation error in case the types don’t match or no user data is stored.

Source

pub fn with_item<F, R>(&mut self, f: F, s: &'static str) -> EncodingResult<R>
where F: FnOnce(&mut Encoder<'_, T>) -> EncodingResult<R>,

Source

pub fn with_variant<F, R>(&mut self, f: F, s: &'static str) -> EncodingResult<R>
where F: FnOnce(&mut Encoder<'_, T>) -> EncodingResult<R>,

Source

pub fn with_field<F, R>(&mut self, f: F, s: &'static str) -> EncodingResult<R>
where F: FnOnce(&mut Encoder<'_, T>) -> EncodingResult<R>,

Source

pub fn with_index<F, R>(&mut self, f: F, s: usize) -> EncodingResult<R>
where F: FnOnce(&mut Encoder<'_, T>) -> EncodingResult<R>,

Source§

impl<T: Write> Encoder<'_, T>

Source

pub fn encode_value<V: Encode<T>>(&mut self, value: V) -> EncodingResult<()>

Method for convenience.

Encodes a value using self as the encoder.

This method is not magic - it is literally defined as value.encode(self)

Source§

impl<T: Read> Encoder<'_, T>

Source

pub fn decode_value<V: Decode<T>>(&mut self) -> EncodingResult<V>

Method for convenience.

Decodes a value using self as the decoder.

This method is not magic - it is literally defined as V::decode(self)

Source§

impl<'a, T> Encoder<'a, T>

Source

pub fn finish(self) -> (T, Context<'a>)

Source§

impl<T: Write> Encoder<'_, T>

Source

pub fn write_u8(&mut self, value: u8) -> EncodingResult<()>

Encodes a u8 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_u8_with( &mut self, value: u8, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a u8 to the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn write_i8(&mut self, value: i8) -> EncodingResult<()>

Encodes a i8 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_i8_with( &mut self, value: i8, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a i8 to the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn write_u16(&mut self, value: u16) -> EncodingResult<()>

Encodes a u16 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_u16_with( &mut self, value: u16, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a u16 to the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn write_i16(&mut self, value: i16) -> EncodingResult<()>

Encodes a i16 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_i16_with( &mut self, value: i16, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a i16 to the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn write_u32(&mut self, value: u32) -> EncodingResult<()>

Encodes a u32 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_u32_with( &mut self, value: u32, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a u32 to the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn write_i32(&mut self, value: i32) -> EncodingResult<()>

Encodes a i32 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_i32_with( &mut self, value: i32, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a i32 to the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn write_u64(&mut self, value: u64) -> EncodingResult<()>

Encodes a u64 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_u64_with( &mut self, value: u64, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a u64 to the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn write_i64(&mut self, value: i64) -> EncodingResult<()>

Encodes a i64 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_i64_with( &mut self, value: i64, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a i64 to the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn write_u128(&mut self, value: u128) -> EncodingResult<()>

Encodes a u128 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_u128_with( &mut self, value: u128, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a u128 to the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn write_i128(&mut self, value: i128) -> EncodingResult<()>

Encodes a i128 to the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn write_i128_with( &mut self, value: i128, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a i128 to the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn write_usize(&mut self, value: usize) -> EncodingResult<()>

Encodes an usize.

If the size flatten variable is set to Some, this function checks that the value matches but then returns immediately without writing, otherwise it will encode the given usize to the underlying stream according to the endianness, numerical encoding and bit-width in the encoder’s state, with an additional check that the value does not exceed the max size.

Source

pub fn write_isize(&mut self, value: isize) -> EncodingResult<()>

Encodes a isize to the underlying stream, according to the endianness, numerical encoding and bit-width in the encoder’s state.

Source

pub fn write_uvariant<V>(&mut self, value: V) -> EncodingResult<()>
where Opaque: From<V>, V: Sign<Sign = Unsigned>,

Encodes an unsigned Variant.

If the Variant flatten variable is set to Some, this function checks that the value matches but then returns immediately without writing, otherwise it will encode the given Variant to the underlying stream according to the endianness, numerical encoding and bit-width in the encoder’s state.

Source

pub fn write_ivariant<V>(&mut self, value: V) -> EncodingResult<()>
where Opaque: From<V>, V: Sign<Sign = Signed>,

Encodes a signed Variant.

If the Variant flatten variable is set to Some, this function checks that the value matches but then returns immediately without writing, otherwise it will encode the given Variant to the underlying stream according to the endianness, numerical encoding and bit-width in the encoder’s state.

Source

pub fn write_bool(&mut self, value: bool) -> EncodingResult<()>

Encodes a boolean value.

It is guaranteed that, if value is true, a single u8 will be written to the underlying stream with the value 1, and if value is false, with a value of 0.

If the bool flatten variable is set to Some, this function checks that the value matches but then returns immediately without writing, otherwise it will encode the given bool as described above.

Source

pub fn write_char(&mut self, value: char) -> EncodingResult<()>

Encodes a char to the underlying stream, according to the endianness and string encoding in the encoder’s state.

Source

pub fn write_char_with( &mut self, value: char, encoding: StrEncoding, endianness: Endianness, ) -> EncodingResult<()>

Encodes a char to the underlying stream, according to the endianness and string encoding passed as parameters.

Source

pub fn write_f32(&mut self, value: f32) -> EncodingResult<()>

Encodes a f32 to the underlying stream, ignoring the numeric encoding but respecting the endianness. Equivalent of Self::write_u32(value.to_bits()) with the numeric encoding set to Fixed

Source

pub fn write_f64(&mut self, value: f64) -> EncodingResult<()>

Encodes a f64 to the underlying stream, ignoring the numeric encoding but respecting the endianness. Equivalent of Self::write_u64(value.to_bits()) with the numeric encoding set to Fixed

Source

pub fn write_str<S>(&mut self, string: S) -> EncodingResult<()>
where S: IntoIterator<Item = char, IntoIter: Clone>,

Encodes a string to the underlying stream, according to the endianness, string encoding and string-length encoding in the encoder’s state. Anything whose chars can be iterated over is considered a string.

§Example

let mut encoder = Encoder::new(Zero, Context::new());
encoder.write_str("Hello, world!".chars()).unwrap();
Source

pub fn write_str_with<S>( &mut self, string: S, encoding: StrEncoding, endianness: Endianness, len_encoding: StrLen, ) -> EncodingResult<()>
where S: IntoIterator<Item = char, IntoIter: Clone>,

Encodes a string to the underlying stream, according to the endianness, string encoding and string-length encoding passed as parameters. Anything whose chars can be iterated over is considered a string.

§Example

let mut encoder = Encoder::new(Zero, Context::new());
encoder.write_str_with(
    "Goodbye, world :(".chars(),
    StrEncoding::Utf16,
    Endianness::BigEndian,
    StrLen::NullTerminated
).unwrap();
Source

pub fn write_byte(&mut self, byte: u8) -> EncodingResult<()>

Writes a single byte to the underlying stream as-is.

Source

pub fn write_bytes(&mut self, bytes: &[u8]) -> EncodingResult<()>

Writes the given slice to the underlying stream as-is.

Source§

impl<T: Read> Encoder<'_, T>

Source

pub fn read_u8(&mut self) -> EncodingResult<u8>

Decodes a u8 from the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn read_u8_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<u8>

Decodes a u8 from the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn read_i8(&mut self) -> EncodingResult<i8>

Decodes a i8 from the underlying stream, according to the endianness and numerical encoding in the encoder’s context

Source

pub fn read_i8_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<i8>

Decodes a i8 from the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn read_u16(&mut self) -> EncodingResult<u16>

Decodes a u16 from the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn read_u16_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<u16>

Decodes a u16 from the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn read_i16(&mut self) -> EncodingResult<i16>

Decodes a i16 from the underlying stream, according to the endianness and numerical encoding in the encoder’s context

Source

pub fn read_i16_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<i16>

Decodes a i16 from the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn read_u32(&mut self) -> EncodingResult<u32>

Decodes a u32 from the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn read_u32_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<u32>

Decodes a u32 from the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn read_i32(&mut self) -> EncodingResult<i32>

Decodes a i32 from the underlying stream, according to the endianness and numerical encoding in the encoder’s context

Source

pub fn read_i32_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<i32>

Decodes a i32 from the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn read_u64(&mut self) -> EncodingResult<u64>

Decodes a u64 from the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn read_u64_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<u64>

Decodes a u64 from the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn read_i64(&mut self) -> EncodingResult<i64>

Decodes a i64 from the underlying stream, according to the endianness and numerical encoding in the encoder’s context

Source

pub fn read_i64_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<i64>

Decodes a i64 from the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn read_u128(&mut self) -> EncodingResult<u128>

Decodes a u128 from the underlying stream, according to the endianness and numerical encoding in the encoder’s state

Source

pub fn read_u128_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<u128>

Decodes a u128 from the underlying stream, according to the endianness and numerical passed as parameters

Source

pub fn read_i128(&mut self) -> EncodingResult<i128>

Decodes a i128 from the underlying stream, according to the endianness and numerical encoding in the encoder’s context

Source

pub fn read_i128_with( &mut self, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<i128>

Decodes a i128 from the underlying stream, according to the endianness and numerical encoding passed as parameters

Source

pub fn read_usize(&mut self) -> EncodingResult<usize>

Decodes an usize.

If the usize flatten variable is set to Some, this function will return its value without reading, otherwise it will decode an usize from the underlying stream, according to the endianness, numerical encoding and bit-width in the encoder’s state, with an additional check that the size does not exceed the max size.

Source

pub fn read_isize(&mut self) -> EncodingResult<isize>

Decodes a isize from the underlying stream, according to the endianness, numerical encoding and bit-width in the encoder’s state

Source

pub fn read_uvariant<V>(&mut self) -> EncodingResult<V>
where V: Sign<Sign = Unsigned>, Opaque: TryInto<V, Error = EncodingError>,

Decodes an unsigned Variant.

If the Variant flatten variable is set to Some, this function will return its value without reading, otherwise it will decode a Variant from the underlying stream, according to the endianness, numerical encoding and bit-width in the encoder’s state.

Source

pub fn read_ivariant<V>(&mut self) -> EncodingResult<V>
where V: Sign<Sign = Signed>, Opaque: TryInto<V, Error = EncodingError>,

Decodes a signed Variant.

If the Variant flatten variable is set to Some, this function will return its value without reading, otherwise it will decode a Variant from the underlying stream, according to the endianness, numerical encoding and bit-width in the encoder’s state.

Source

pub fn read_bool(&mut self) -> EncodingResult<bool>

Decodes a boolean value.

It is guaranteed that, one u8 is read from the underlying stream and, if it’s equal to 1, true is returned, if it’s equal to 0, false is returned, for any other value an InvalidBool error will be returned.

If the bool flatten variable is set to Some, then its value is returned without reading, otherwise the boolean is decoded as described above.

Source

pub fn read_char(&mut self) -> EncodingResult<char>

Decodes a char from the underlying stream, according to the endianness and string encoding in the encoder’s state.

Source

pub fn read_f32(&mut self) -> EncodingResult<f32>

Decodes a f32 from the underlying stream, ignoring the numeric encoding but respecting the endianness. Equivalent of f32::from_bits(self.read_u32()) with the numeric encoding set to NumEncoding::Fixed.

Source

pub fn read_f64(&mut self) -> EncodingResult<f64>

Decodes a f64 from the underlying stream, ignoring the numeric encoding but respecting the endianness. Equivalent of f64::from_bits(self.read_u64()) with the numeric encoding set to NumEncoding::Fixed.

Source

pub fn read_str<S>(&mut self) -> EncodingResult<S>
where S: FromIterator<char>,

Decodes a String from the underlying stream, according to the endianness, and string encoding in the encoder’s state.

Source

pub fn read_str_with<S>( &mut self, encoding: StrEncoding, endianness: Endianness, len_encoding: StrLen, ) -> EncodingResult<S>
where S: FromIterator<char>,

Decodes a String from the underlying stream, according to the endianness, and string encoding passed as parameters.

Source

pub fn read_byte(&mut self) -> EncodingResult<u8>

Reads a single byte from the stream.

Source

pub fn read_bytes(&mut self, buf: &mut [u8]) -> EncodingResult<()>

Reads buf.len() bytes from the stream to the buffer as-is.

Source§

impl<'data, T: BorrowRead<'data>> Encoder<'_, T>

Source

pub fn peek_bytes(&self, len: usize) -> EncodingResult<&'data [u8]>

Returns a reference to len bytes in the stream, without advancing it.

This forwards the call to BorrowRead::peek, meaning multiple calls produce the same output.

§Example
use ender::{Context, Encoder};
use ender::io::Slice;

let slice = [0, 7, 15, 42, 2];
let encoder = Encoder::new(Slice::new(&slice), Context::new());

let first_peek = encoder.peek_bytes(3).unwrap();
let second_peek = encoder.peek_bytes(3).unwrap();

assert_eq!(first_peek, second_peek);
Source

pub fn borrow_byte_slice(&mut self, len: usize) -> EncodingResult<&'data [u8]>

Borrows a u8 slice of length length from the encoder, without performing any additional checks.

Source

pub fn borrow_u8_slice( &mut self, len: usize, num_encoding: NumEncoding, ) -> EncodingResult<&'data [u8]>

Borrows a u8 slice of length length from the encoder, checking that the NumEncoding is borrowable.

Source

pub fn borrow_u16_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [u16]>

Borrows a u16 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_u32_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [u32]>

Borrows a u32 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_u64_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [u64]>

Borrows a u64 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_u128_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [u128]>

Borrows a u128 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_i8_slice( &mut self, len: usize, num_encoding: NumEncoding, ) -> EncodingResult<&'data [i8]>

Borrows a u8 slice of length length from the encoder, checking that the NumEncoding is borrowable.

Source

pub fn borrow_i16_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [i16]>

Borrows a i16 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_i32_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [i32]>

Borrows a i32 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_i64_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [i64]>

Borrows a i64 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_i128_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [i128]>

Borrows a i128 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_f32_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [f32]>

Borrows a f32 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_f64_slice( &mut self, length: usize, num_encoding: NumEncoding, endianness: Endianness, ) -> EncodingResult<&'data [f64]>

Borrows a f64 slice of length length from the encoder, checking that the Endianness and alignment match those of the system and that the NumEncoding is borrowable

Source

pub fn borrow_usize_slice( &mut self, len: usize, num_encoding: NumEncoding, endianness: Endianness, bit_width: BitWidth, ) -> EncodingResult<&'data [usize]>

Borrows a usize slice of length length from the encoder.

Checks that the Endianness and BitWidth match those of the target system, and that the NumEncoding is borrowable

Source

pub fn borrow_isize_slice( &mut self, len: usize, num_encoding: NumEncoding, endianness: Endianness, bit_width: BitWidth, ) -> EncodingResult<&'data [isize]>

Borrows a isize slice of length length from the encoder.

Checks that the Endianness and BitWidth match those of the target system, and that the NumEncoding is borrowable

Source§

impl<T: Seek> Encoder<'_, T>

Source

pub fn stream_position(&mut self) -> EncodingResult<usize>

Returns the current stream position as a byte offset from the start.

Source

pub fn seek(&mut self, seek: SeekFrom) -> EncodingResult<usize>

Performs a seek operation on the underlying stream using the given seek argument.

Source

pub fn with_seek<F, R>(&mut self, f: F, seek: SeekFrom) -> EncodingResult<R>
where F: FnOnce(&mut Encoder<'_, T>) -> EncodingResult<R>,

Performs a seek operation on the underlying stream using the given seek argument, calls the closure, then seeks back to the original position.

Trait Implementations§

Source§

impl<'a, T: Clone> Clone for Encoder<'a, T>

Source§

fn clone(&self) -> Encoder<'a, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'de, T: Read> Deserializer<'de> for &mut Encoder<'de, T>

Available on crate feature serde only.
Source§

type Error = EncodingError

The error type that can be returned if some error occurs during deserialization.
Source§

fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Require the Deserializer to figure out how to drive the visitor based on what data type is in the input. Read more
Source§

fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a bool value.
Source§

fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i8 value.
Source§

fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i16 value.
Source§

fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i32 value.
Source§

fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i64 value.
Source§

fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an i128 value. Read more
Source§

fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u8 value.
Source§

fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u16 value.
Source§

fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u32 value.
Source§

fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a u64 value.
Source§

fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an u128 value. Read more
Source§

fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f32 value.
Source§

fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a f64 value.
Source§

fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a char value.
Source§

fn deserialize_str<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_string<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a string value and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and does not benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a byte array and would benefit from taking ownership of buffered data owned by the Deserializer. Read more
Source§

fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an optional value. Read more
Source§

fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit value.
Source§

fn deserialize_unit_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a unit struct with a particular name.
Source§

fn deserialize_newtype_struct<V>( self, _name: &'static str, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a newtype struct with a particular name.
Source§

fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values.
Source§

fn deserialize_tuple<V>( self, len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a sequence of values and knows how many values there are without looking at the serialized data.
Source§

fn deserialize_tuple_struct<V>( self, _name: &'static str, len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a tuple struct with a particular name and number of fields.
Source§

fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a map of key-value pairs.
Source§

fn deserialize_struct<V>( self, _name: &'static str, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting a struct with a particular name and fields.
Source§

fn deserialize_enum<V>( self, _name: &'static str, _variants: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting an enum value with a particular name and possible variants.
Source§

fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type is expecting the name of a struct field or the discriminant of an enum variant.
Source§

fn deserialize_ignored_any<V>( self, _visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Hint that the Deserialize type needs to deserialize a value whose type doesn’t matter because it is ignored. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Deserialize implementations should expect to deserialize their human-readable form. Read more
Source§

impl<'de, T: Read> EnumAccess<'de> for &mut Encoder<'de, T>

Available on crate feature serde only.
Source§

type Error = EncodingError

The error type that can be returned if some error occurs during deserialization.
Source§

type Variant = &mut Encoder<'de, T>

The Visitor that will be used to deserialize the content of the enum variant.
Source§

fn variant_seed<V>( self, seed: V, ) -> Result<(V::Value, Self::Variant), Self::Error>
where V: DeserializeSeed<'de>,

variant is called to identify which variant to deserialize. Read more
Source§

fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
where V: Deserialize<'de>,

variant is called to identify which variant to deserialize. Read more
Source§

impl<T: Write> SerializeMap for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_key<G>(&mut self, key: &G) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a map key. Read more
Source§

fn serialize_value<G>(&mut self, value: &G) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a map value. Read more
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a map.
Source§

fn serialize_entry<K, V>( &mut self, key: &K, value: &V, ) -> Result<(), Self::Error>
where K: Serialize + ?Sized, V: Serialize + ?Sized,

Serialize a map entry consisting of a key and a value. Read more
Source§

impl<T: Write> SerializeSeq for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_element<G>(&mut self, value: &G) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a sequence element.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a sequence.
Source§

impl<T: Write> SerializeStruct for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_field<G>( &mut self, _key: &'static str, value: &G, ) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a struct field.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a struct.
Source§

fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error>

Indicate that a struct field has been skipped. Read more
Source§

impl<T: Write> SerializeStructVariant for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_field<G>( &mut self, _key: &'static str, value: &G, ) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a struct variant field.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a struct variant.
Source§

fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error>

Indicate that a struct variant field has been skipped. Read more
Source§

impl<T: Write> SerializeTuple for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_element<G>(&mut self, value: &G) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a tuple element.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a tuple.
Source§

impl<T: Write> SerializeTupleStruct for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_field<G>(&mut self, value: &G) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a tuple struct field.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a tuple struct.
Source§

impl<T: Write> SerializeTupleVariant for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = EncodingError

Must match the Error type of our Serializer.
Source§

fn serialize_field<G>(&mut self, value: &G) -> Result<(), Self::Error>
where G: Serialize + ?Sized,

Serialize a tuple variant field.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a tuple variant.
Source§

impl<T: Write> Serializer for &mut Encoder<'_, T>

Available on crate feature serde only.
Source§

type Ok = ()

The output type produced by this Serializer during successful serialization. Most serializers that produce text or binary output should set Ok = () and serialize into an io::Write or buffer contained within the Serializer instance. Serializers that build in-memory data structures may be simplified by using Ok to propagate the data structure around.
Source§

type Error = EncodingError

The error type when some error occurs during serialization.
Source§

type SerializeSeq = &mut Encoder<'_, T>

Type returned from serialize_seq for serializing the content of the sequence.
Source§

type SerializeTuple = &mut Encoder<'_, T>

Type returned from serialize_tuple for serializing the content of the tuple.
Source§

type SerializeTupleStruct = &mut Encoder<'_, T>

Type returned from serialize_tuple_struct for serializing the content of the tuple struct.
Source§

type SerializeTupleVariant = &mut Encoder<'_, T>

Type returned from serialize_tuple_variant for serializing the content of the tuple variant.
Source§

type SerializeMap = &mut Encoder<'_, T>

Type returned from serialize_map for serializing the content of the map.
Source§

type SerializeStruct = &mut Encoder<'_, T>

Type returned from serialize_struct for serializing the content of the struct.
Source§

type SerializeStructVariant = &mut Encoder<'_, T>

Type returned from serialize_struct_variant for serializing the content of the struct variant.
Source§

fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>

Serialize a bool value. Read more
Source§

fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>

Serialize an i8 value. Read more
Source§

fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>

Serialize an i16 value. Read more
Source§

fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>

Serialize an i32 value. Read more
Source§

fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>

Serialize an i64 value. Read more
Source§

fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>

Serialize an i128 value. Read more
Source§

fn serialize_u8(self, v: u8) -> Result<Self::Ok, Self::Error>

Serialize a u8 value. Read more
Source§

fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>

Serialize a u16 value. Read more
Source§

fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>

Serialize a u32 value. Read more
Source§

fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>

Serialize a u64 value. Read more
Source§

fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>

Serialize a u128 value. Read more
Source§

fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>

Serialize an f32 value. Read more
Source§

fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>

Serialize an f64 value. Read more
Source§

fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>

Serialize a character. Read more
Source§

fn serialize_str(self, v: &str) -> Result<Self::Ok, Self::Error>

Serialize a &str. Read more
Source§

fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>

Serialize a chunk of raw byte data. Read more
Source§

fn serialize_none(self) -> Result<Self::Ok, Self::Error>

Serialize a None value. Read more
Source§

fn serialize_some<G>(self, value: &G) -> Result<Self::Ok, Self::Error>
where G: Serialize + ?Sized,

Serialize a Some(T) value. Read more
Source§

fn serialize_unit(self) -> Result<Self::Ok, Self::Error>

Serialize a () value. Read more
Source§

fn serialize_unit_struct( self, _name: &'static str, ) -> Result<Self::Ok, Self::Error>

Serialize a unit struct like struct Unit or PhantomData<T>. Read more
Source§

fn serialize_unit_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, ) -> Result<Self::Ok, Self::Error>

Serialize a unit variant like E::A in enum E { A, B }. Read more
Source§

fn serialize_newtype_struct<G>( self, _name: &'static str, value: &G, ) -> Result<Self::Ok, Self::Error>
where G: Serialize + ?Sized,

Serialize a newtype struct like struct Millimeters(u8). Read more
Source§

fn serialize_newtype_variant<G>( self, _name: &'static str, variant_index: u32, _variant: &'static str, value: &G, ) -> Result<Self::Ok, Self::Error>
where G: Serialize + ?Sized,

Serialize a newtype variant like E::N in enum E { N(u8) }. Read more
Source§

fn serialize_seq( self, len: Option<usize>, ) -> Result<Self::SerializeSeq, Self::Error>

Begin to serialize a variably sized sequence. This call must be followed by zero or more calls to serialize_element, then a call to end. Read more
Source§

fn serialize_tuple( self, _len: usize, ) -> Result<Self::SerializeTuple, Self::Error>

Begin to serialize a statically sized sequence whose length will be known at deserialization time without looking at the serialized data. This call must be followed by zero or more calls to serialize_element, then a call to end. Read more
Source§

fn serialize_tuple_struct( self, _name: &'static str, _len: usize, ) -> Result<Self::SerializeTupleStruct, Self::Error>

Begin to serialize a tuple struct like struct Rgb(u8, u8, u8). This call must be followed by zero or more calls to serialize_field, then a call to end. Read more
Source§

fn serialize_tuple_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize, ) -> Result<Self::SerializeTupleVariant, Self::Error>

Begin to serialize a tuple variant like E::T in enum E { T(u8, u8) }. This call must be followed by zero or more calls to serialize_field, then a call to end. Read more
Source§

fn serialize_map( self, len: Option<usize>, ) -> Result<Self::SerializeMap, Self::Error>

Begin to serialize a map. This call must be followed by zero or more calls to serialize_key and serialize_value, then a call to end. Read more
Source§

fn serialize_struct( self, _name: &'static str, _len: usize, ) -> Result<Self::SerializeStruct, Self::Error>

Begin to serialize a struct like struct Rgb { r: u8, g: u8, b: u8 }. This call must be followed by zero or more calls to serialize_field, then a call to end. Read more
Source§

fn serialize_struct_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize, ) -> Result<Self::SerializeStructVariant, Self::Error>

Begin to serialize a struct variant like E::S in enum E { S { r: u8, g: u8, b: u8 } }. This call must be followed by zero or more calls to serialize_field, then a call to end. Read more
Source§

fn is_human_readable(&self) -> bool

Determine whether Serialize implementations should serialize in human-readable form. Read more
Source§

fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>

Collect an iterator as a sequence. Read more
Source§

fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>
where K: Serialize, V: Serialize, I: IntoIterator<Item = (K, V)>,

Collect an iterator as a map. Read more
Source§

fn collect_str<T>(self, value: &T) -> Result<Self::Ok, Self::Error>
where T: Display + ?Sized,

Available on crate features std or alloc only.
Serialize a string produced by an implementation of Display. Read more
Source§

impl<'de, T: Read> VariantAccess<'de> for &mut Encoder<'de, T>

Available on crate feature serde only.
Source§

type Error = EncodingError

The error type that can be returned if some error occurs during deserialization. Must match the error type of our EnumAccess.
Source§

fn unit_variant(self) -> Result<(), Self::Error>

Called when deserializing a variant with no values. Read more
Source§

fn newtype_variant_seed<G>(self, seed: G) -> Result<G::Value, Self::Error>
where G: DeserializeSeed<'de>,

Called when deserializing a variant with a single value. Read more
Source§

fn tuple_variant<V>( self, len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a tuple-like variant. Read more
Source§

fn struct_variant<V>( self, fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a struct-like variant. Read more
Source§

fn newtype_variant<T>(self) -> Result<T, Self::Error>
where T: Deserialize<'de>,

Called when deserializing a variant with a single value. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for Encoder<'a, T>
where T: Freeze,

§

impl<'a, T> !RefUnwindSafe for Encoder<'a, T>

§

impl<'a, T> !Send for Encoder<'a, T>

§

impl<'a, T> !Sync for Encoder<'a, T>

§

impl<'a, T> Unpin for Encoder<'a, T>
where T: Unpin,

§

impl<'a, T> !UnwindSafe for Encoder<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoResult<T> for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.