#[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
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.stream: TThe underlying stream
ctxt: Context<'a>The state
stack: Stackdebug only.The stack
Implementations§
Source§impl<'a, T> Encoder<'a, T>
impl<'a, T> Encoder<'a, T>
Sourcepub fn swap_stream(&mut self, new: T) -> T
pub fn swap_stream(&mut self, new: T) -> T
Replaces the underlying stream with the new one, returning the previous value
Sourcepub fn user_data<U: Any>(&self) -> EncodingResult<&U>
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.
pub fn with_item<F, R>(&mut self, f: F, s: &'static str) -> EncodingResult<R>
pub fn with_variant<F, R>(&mut self, f: F, s: &'static str) -> EncodingResult<R>
pub fn with_field<F, R>(&mut self, f: F, s: &'static str) -> EncodingResult<R>
pub fn with_index<F, R>(&mut self, f: F, s: usize) -> EncodingResult<R>
Source§impl<T: Write> Encoder<'_, T>
impl<T: Write> Encoder<'_, T>
Sourcepub fn encode_value<V: Encode<T>>(&mut self, value: V) -> EncodingResult<()>
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>
impl<T: Read> Encoder<'_, T>
Sourcepub fn decode_value<V: Decode<T>>(&mut self) -> EncodingResult<V>
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<T: Write> Encoder<'_, T>
impl<T: Write> Encoder<'_, T>
Sourcepub fn write_u8(&mut self, value: u8) -> EncodingResult<()>
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
Sourcepub fn write_u8_with(
&mut self,
value: u8,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_i8(&mut self, value: i8) -> EncodingResult<()>
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
Sourcepub fn write_i8_with(
&mut self,
value: i8,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_u16(&mut self, value: u16) -> EncodingResult<()>
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
Sourcepub fn write_u16_with(
&mut self,
value: u16,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_i16(&mut self, value: i16) -> EncodingResult<()>
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
Sourcepub fn write_i16_with(
&mut self,
value: i16,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_u32(&mut self, value: u32) -> EncodingResult<()>
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
Sourcepub fn write_u32_with(
&mut self,
value: u32,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_i32(&mut self, value: i32) -> EncodingResult<()>
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
Sourcepub fn write_i32_with(
&mut self,
value: i32,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_u64(&mut self, value: u64) -> EncodingResult<()>
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
Sourcepub fn write_u64_with(
&mut self,
value: u64,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_i64(&mut self, value: i64) -> EncodingResult<()>
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
Sourcepub fn write_i64_with(
&mut self,
value: i64,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_u128(&mut self, value: u128) -> EncodingResult<()>
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
Sourcepub fn write_u128_with(
&mut self,
value: u128,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_i128(&mut self, value: i128) -> EncodingResult<()>
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
Sourcepub fn write_i128_with(
&mut self,
value: i128,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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
Sourcepub fn write_usize(&mut self, value: usize) -> EncodingResult<()>
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.
Sourcepub fn write_isize(&mut self, value: isize) -> EncodingResult<()>
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.
Sourcepub fn write_uvariant<V>(&mut self, value: V) -> EncodingResult<()>
pub fn write_uvariant<V>(&mut self, value: V) -> EncodingResult<()>
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.
Sourcepub fn write_ivariant<V>(&mut self, value: V) -> EncodingResult<()>
pub fn write_ivariant<V>(&mut self, value: V) -> EncodingResult<()>
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.
Sourcepub fn write_bool(&mut self, value: bool) -> EncodingResult<()>
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.
Sourcepub fn write_char(&mut self, value: char) -> EncodingResult<()>
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.
Sourcepub fn write_char_with(
&mut self,
value: char,
encoding: StrEncoding,
endianness: Endianness,
) -> EncodingResult<()>
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.
Sourcepub fn write_f32(&mut self, value: f32) -> EncodingResult<()>
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
Sourcepub fn write_f64(&mut self, value: f64) -> EncodingResult<()>
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
Sourcepub fn write_str<S>(&mut self, string: S) -> EncodingResult<()>
pub fn write_str<S>(&mut self, string: S) -> EncodingResult<()>
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();Sourcepub fn write_str_with<S>(
&mut self,
string: S,
encoding: StrEncoding,
endianness: Endianness,
len_encoding: StrLen,
) -> EncodingResult<()>
pub fn write_str_with<S>( &mut self, string: S, encoding: StrEncoding, endianness: Endianness, len_encoding: StrLen, ) -> EncodingResult<()>
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();Sourcepub fn write_byte(&mut self, byte: u8) -> EncodingResult<()>
pub fn write_byte(&mut self, byte: u8) -> EncodingResult<()>
Writes a single byte to the underlying stream as-is.
Sourcepub fn write_bytes(&mut self, bytes: &[u8]) -> EncodingResult<()>
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>
impl<T: Read> Encoder<'_, T>
Sourcepub fn read_u8(&mut self) -> EncodingResult<u8>
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
Sourcepub fn read_u8_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<u8>
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
Sourcepub fn read_i8(&mut self) -> EncodingResult<i8>
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
Sourcepub fn read_i8_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<i8>
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
Sourcepub fn read_u16(&mut self) -> EncodingResult<u16>
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
Sourcepub fn read_u16_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<u16>
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
Sourcepub fn read_i16(&mut self) -> EncodingResult<i16>
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
Sourcepub fn read_i16_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<i16>
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
Sourcepub fn read_u32(&mut self) -> EncodingResult<u32>
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
Sourcepub fn read_u32_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<u32>
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
Sourcepub fn read_i32(&mut self) -> EncodingResult<i32>
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
Sourcepub fn read_i32_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<i32>
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
Sourcepub fn read_u64(&mut self) -> EncodingResult<u64>
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
Sourcepub fn read_u64_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<u64>
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
Sourcepub fn read_i64(&mut self) -> EncodingResult<i64>
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
Sourcepub fn read_i64_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<i64>
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
Sourcepub fn read_u128(&mut self) -> EncodingResult<u128>
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
Sourcepub fn read_u128_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<u128>
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
Sourcepub fn read_i128(&mut self) -> EncodingResult<i128>
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
Sourcepub fn read_i128_with(
&mut self,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<i128>
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
Sourcepub fn read_usize(&mut self) -> EncodingResult<usize>
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.
Sourcepub fn read_isize(&mut self) -> EncodingResult<isize>
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
Sourcepub fn read_uvariant<V>(&mut self) -> EncodingResult<V>
pub fn read_uvariant<V>(&mut self) -> EncodingResult<V>
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.
Sourcepub fn read_ivariant<V>(&mut self) -> EncodingResult<V>
pub fn read_ivariant<V>(&mut self) -> EncodingResult<V>
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.
Sourcepub fn read_bool(&mut self) -> EncodingResult<bool>
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.
Sourcepub fn read_char(&mut self) -> EncodingResult<char>
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.
Sourcepub fn read_f32(&mut self) -> EncodingResult<f32>
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.
Sourcepub fn read_f64(&mut self) -> EncodingResult<f64>
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.
Sourcepub fn read_str<S>(&mut self) -> EncodingResult<S>where
S: FromIterator<char>,
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.
Sourcepub fn read_str_with<S>(
&mut self,
encoding: StrEncoding,
endianness: Endianness,
len_encoding: StrLen,
) -> EncodingResult<S>where
S: FromIterator<char>,
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.
Sourcepub fn read_byte(&mut self) -> EncodingResult<u8>
pub fn read_byte(&mut self) -> EncodingResult<u8>
Reads a single byte from the stream.
Sourcepub fn read_bytes(&mut self, buf: &mut [u8]) -> EncodingResult<()>
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>
impl<'data, T: BorrowRead<'data>> Encoder<'_, T>
Sourcepub fn peek_bytes(&self, len: usize) -> EncodingResult<&'data [u8]>
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);Sourcepub fn borrow_byte_slice(&mut self, len: usize) -> EncodingResult<&'data [u8]>
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.
Sourcepub fn borrow_u8_slice(
&mut self,
len: usize,
num_encoding: NumEncoding,
) -> EncodingResult<&'data [u8]>
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.
Sourcepub fn borrow_u16_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [u16]>
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
Sourcepub fn borrow_u32_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [u32]>
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
Sourcepub fn borrow_u64_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [u64]>
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
Sourcepub fn borrow_u128_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [u128]>
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
Sourcepub fn borrow_i8_slice(
&mut self,
len: usize,
num_encoding: NumEncoding,
) -> EncodingResult<&'data [i8]>
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.
Sourcepub fn borrow_i16_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [i16]>
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
Sourcepub fn borrow_i32_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [i32]>
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
Sourcepub fn borrow_i64_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [i64]>
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
Sourcepub fn borrow_i128_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [i128]>
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
Sourcepub fn borrow_f32_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [f32]>
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
Sourcepub fn borrow_f64_slice(
&mut self,
length: usize,
num_encoding: NumEncoding,
endianness: Endianness,
) -> EncodingResult<&'data [f64]>
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
Sourcepub fn borrow_usize_slice(
&mut self,
len: usize,
num_encoding: NumEncoding,
endianness: Endianness,
bit_width: BitWidth,
) -> EncodingResult<&'data [usize]>
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
Sourcepub fn borrow_isize_slice(
&mut self,
len: usize,
num_encoding: NumEncoding,
endianness: Endianness,
bit_width: BitWidth,
) -> EncodingResult<&'data [isize]>
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>
impl<T: Seek> Encoder<'_, T>
Sourcepub fn stream_position(&mut self) -> EncodingResult<usize>
pub fn stream_position(&mut self) -> EncodingResult<usize>
Returns the current stream position as a byte offset from the start.
Sourcepub fn seek(&mut self, seek: SeekFrom) -> EncodingResult<usize>
pub fn seek(&mut self, seek: SeekFrom) -> EncodingResult<usize>
Performs a seek operation on the underlying stream using the given seek
argument.
Sourcepub fn with_seek<F, R>(&mut self, f: F, seek: SeekFrom) -> EncodingResult<R>
pub fn with_seek<F, R>(&mut self, f: F, seek: SeekFrom) -> 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<'de, T: Read> Deserializer<'de> for &mut Encoder<'de, T>
Available on crate feature serde only.
impl<'de, T: Read> Deserializer<'de> for &mut Encoder<'de, T>
serde only.Source§type Error = EncodingError
type Error = EncodingError
Source§fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_any<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserializer to figure out how to drive the visitor based
on what data type is in the input. Read moreSource§fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_bool<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a bool value.Source§fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting an i8 value.Source§fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting an i16 value.Source§fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting an i32 value.Source§fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting an i64 value.Source§fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_i128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Source§fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u8<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a u8 value.Source§fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u16<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a u16 value.Source§fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a u32 value.Source§fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a u64 value.Source§fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_u128<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Source§fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_f32<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a f32 value.Source§fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a f64 value.Source§fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a char value.Source§fn deserialize_str<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_str<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a string value and does
not benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_string<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_string<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a string value and would
benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_bytes<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a byte array and does not
benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_byte_buf<V>(self, _visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting a byte array and would
benefit from taking ownership of buffered data owned by the
Deserializer. Read moreSource§fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_option<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type is expecting an optional value. Read moreSource§fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
fn deserialize_unit<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_unit_struct<V>(
self,
_name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_newtype_struct<V>(
self,
_name: &'static str,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_seq<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_tuple<V>(
self,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_tuple_struct<V>(
self,
_name: &'static str,
len: usize,
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_map<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_struct<V>(
self,
_name: &'static str,
fields: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_enum<V>(
self,
_name: &'static str,
_variants: &'static [&'static str],
visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
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>,
fn deserialize_ignored_any<V>(
self,
_visitor: V,
) -> Result<V::Value, Self::Error>where
V: Visitor<'de>,
Deserialize type needs to deserialize a value whose type
doesn’t matter because it is ignored. Read moreSource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Deserialize implementations should expect to
deserialize their human-readable form. Read moreSource§impl<'de, T: Read> EnumAccess<'de> for &mut Encoder<'de, T>
Available on crate feature serde only.
impl<'de, T: Read> EnumAccess<'de> for &mut Encoder<'de, T>
serde only.Source§type Error = EncodingError
type Error = EncodingError
Source§type Variant = &mut Encoder<'de, T>
type Variant = &mut Encoder<'de, T>
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>,
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 moreSource§impl<T: Write> SerializeMap for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeMap for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> SerializeSeq for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeSeq for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> SerializeStruct for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeStruct for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> SerializeStructVariant for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeStructVariant for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> SerializeTuple for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeTuple for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> SerializeTupleStruct for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeTupleStruct for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> SerializeTupleVariant for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> SerializeTupleVariant for &mut Encoder<'_, T>
serde only.Source§impl<T: Write> Serializer for &mut Encoder<'_, T>
Available on crate feature serde only.
impl<T: Write> Serializer for &mut Encoder<'_, T>
serde only.Source§type Ok = ()
type Ok = ()
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
type Error = EncodingError
Source§type SerializeSeq = &mut Encoder<'_, T>
type SerializeSeq = &mut Encoder<'_, T>
serialize_seq for serializing the content of the
sequence.Source§type SerializeTuple = &mut Encoder<'_, T>
type SerializeTuple = &mut Encoder<'_, T>
serialize_tuple for serializing the content of
the tuple.Source§type SerializeTupleStruct = &mut Encoder<'_, T>
type SerializeTupleStruct = &mut Encoder<'_, T>
serialize_tuple_struct for serializing the
content of the tuple struct.Source§type SerializeTupleVariant = &mut Encoder<'_, T>
type SerializeTupleVariant = &mut Encoder<'_, T>
serialize_tuple_variant for serializing the
content of the tuple variant.Source§type SerializeMap = &mut Encoder<'_, T>
type SerializeMap = &mut Encoder<'_, T>
serialize_map for serializing the content of the
map.Source§type SerializeStruct = &mut Encoder<'_, T>
type SerializeStruct = &mut Encoder<'_, T>
serialize_struct for serializing the content of
the struct.Source§type SerializeStructVariant = &mut Encoder<'_, T>
type SerializeStructVariant = &mut Encoder<'_, T>
serialize_struct_variant for serializing the
content of the struct variant.Source§fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>
fn serialize_bool(self, v: bool) -> Result<Self::Ok, Self::Error>
bool value. Read moreSource§fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>
fn serialize_i8(self, v: i8) -> Result<Self::Ok, Self::Error>
i8 value. Read moreSource§fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>
fn serialize_i16(self, v: i16) -> Result<Self::Ok, Self::Error>
i16 value. Read moreSource§fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>
fn serialize_i32(self, v: i32) -> Result<Self::Ok, Self::Error>
i32 value. Read moreSource§fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>
fn serialize_i64(self, v: i64) -> Result<Self::Ok, Self::Error>
i64 value. Read moreSource§fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>
fn serialize_i128(self, v: i128) -> Result<Self::Ok, Self::Error>
i128 value. Read moreSource§fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>
fn serialize_u16(self, v: u16) -> Result<Self::Ok, Self::Error>
u16 value. Read moreSource§fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>
fn serialize_u32(self, v: u32) -> Result<Self::Ok, Self::Error>
u32 value. Read moreSource§fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>
fn serialize_u64(self, v: u64) -> Result<Self::Ok, Self::Error>
u64 value. Read moreSource§fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>
fn serialize_u128(self, v: u128) -> Result<Self::Ok, Self::Error>
u128 value. Read moreSource§fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>
fn serialize_f32(self, v: f32) -> Result<Self::Ok, Self::Error>
f32 value. Read moreSource§fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>
fn serialize_f64(self, v: f64) -> Result<Self::Ok, Self::Error>
f64 value. Read moreSource§fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>
fn serialize_char(self, v: char) -> Result<Self::Ok, Self::Error>
Source§fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>
fn serialize_bytes(self, v: &[u8]) -> Result<Self::Ok, Self::Error>
Source§fn serialize_unit_variant(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
) -> Result<Self::Ok, Self::Error>
fn serialize_unit_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, ) -> Result<Self::Ok, Self::Error>
Source§fn serialize_newtype_struct<G>(
self,
_name: &'static str,
value: &G,
) -> Result<Self::Ok, Self::Error>
fn serialize_newtype_struct<G>( self, _name: &'static str, value: &G, ) -> Result<Self::Ok, Self::Error>
struct Millimeters(u8). Read moreSource§fn serialize_newtype_variant<G>(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
value: &G,
) -> Result<Self::Ok, Self::Error>
fn serialize_newtype_variant<G>( self, _name: &'static str, variant_index: u32, _variant: &'static str, value: &G, ) -> Result<Self::Ok, Self::Error>
Source§fn serialize_seq(
self,
len: Option<usize>,
) -> Result<Self::SerializeSeq, Self::Error>
fn serialize_seq( self, len: Option<usize>, ) -> Result<Self::SerializeSeq, Self::Error>
serialize_element, then a call to
end. Read moreSource§fn serialize_tuple(
self,
_len: usize,
) -> Result<Self::SerializeTuple, Self::Error>
fn serialize_tuple( self, _len: usize, ) -> Result<Self::SerializeTuple, Self::Error>
serialize_element,
then a call to end. Read moreSource§fn serialize_tuple_struct(
self,
_name: &'static str,
_len: usize,
) -> Result<Self::SerializeTupleStruct, Self::Error>
fn serialize_tuple_struct( self, _name: &'static str, _len: usize, ) -> Result<Self::SerializeTupleStruct, Self::Error>
struct Rgb(u8, u8, u8). This
call must be followed by zero or more calls to serialize_field, then a
call to end. Read moreSource§fn serialize_tuple_variant(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
_len: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error>
fn serialize_tuple_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize, ) -> Result<Self::SerializeTupleVariant, Self::Error>
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 moreSource§fn serialize_map(
self,
len: Option<usize>,
) -> Result<Self::SerializeMap, Self::Error>
fn serialize_map( self, len: Option<usize>, ) -> Result<Self::SerializeMap, Self::Error>
serialize_key and serialize_value, then a call to end. Read moreSource§fn serialize_struct(
self,
_name: &'static str,
_len: usize,
) -> Result<Self::SerializeStruct, Self::Error>
fn serialize_struct( self, _name: &'static str, _len: usize, ) -> Result<Self::SerializeStruct, Self::Error>
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 moreSource§fn serialize_struct_variant(
self,
_name: &'static str,
variant_index: u32,
_variant: &'static str,
_len: usize,
) -> Result<Self::SerializeStructVariant, Self::Error>
fn serialize_struct_variant( self, _name: &'static str, variant_index: u32, _variant: &'static str, _len: usize, ) -> Result<Self::SerializeStructVariant, Self::Error>
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 moreSource§fn is_human_readable(&self) -> bool
fn is_human_readable(&self) -> bool
Serialize implementations should serialize in
human-readable form. Read moreSource§fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
Source§impl<'de, T: Read> VariantAccess<'de> for &mut Encoder<'de, T>
Available on crate feature serde only.
impl<'de, T: Read> VariantAccess<'de> for &mut Encoder<'de, T>
serde only.Source§type Error = EncodingError
type Error = EncodingError
EnumAccess.