pub struct SerializeError {
what: &'static str,
}Expand description
An error that occurs when serializing an object from this crate.
Serialization, as used in this crate, universally refers to the process
of transforming a structure (like a DFA) into a custom binary format
represented by &[u8]. To this end, serialization is generally infallible.
However, it can fail when caller provided buffer sizes are too small. When
that occurs, a serialization error is reported.
A SerializeError provides no introspection capabilities. Its only
supported operation is conversion to a human readable error message.
This error type implements the std::error::Error trait only when the
std feature is enabled. Otherwise, this type is defined in all
configurations.
Fields§
§what: &'static strThe name of the thing that a buffer is too small for.
Currently, the only kind of serialization error is one that is committed by a caller: providing a destination buffer that is too small to fit the serialized object. This makes sense conceptually, since every valid inhabitant of a type should be serializable.
This is somewhat exposed in the public API of this crate. For example,
the to_bytes_{big,little}_endian APIs return a Vec<u8> and are
guaranteed to never panic or error. This is only possible because the
implementation guarantees that it will allocate a Vec<u8> that is
big enough.
In summary, if a new serialization error kind needs to be added, then it will need careful consideration.
Implementations§
Source§impl SerializeError
impl SerializeError
pub(crate) fn buffer_too_small(what: &'static str) -> SerializeError
Trait Implementations§
Source§impl Debug for SerializeError
impl Debug for SerializeError
Source§impl Display for SerializeError
impl Display for SerializeError
Source§impl Error for SerializeError
Available on crate feature std only.
impl Error for SerializeError
std only.