Skip to main content

Readable

Trait Readable 

Source
pub trait Readable: Sized {
    // Required method
    fn read_from(
        reader: &mut (impl Read + ?Sized),
    ) -> Result<Self, ReadableError>;
}
Expand description

Deserialize a value (possibly variable-length) from a Read source.

This is the more general counterpart to FixedReadable. Variable-length types such as Vec<T>, String, HashMap, and Option<T> implement Readable directly. Fixed-size types get a blanket impl that delegates to FixedReadable.

Prefer the extension method ReadValue::read_value over calling this trait directly.

§Errors

Returns ReadableError if the read fails or the bytes are not a valid encoding.

Required Methods§

Source

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Read a value from reader.

§Errors

Returns ReadableError on I/O failure or decode error.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Readable for CString

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl Readable for IpAddr

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl Readable for PathBuf

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl Readable for SocketAddr

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl Readable for String

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable, G: Readable, H: Readable, I: Readable, J: Readable, K: Readable, L: Readable> Readable for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable, G: Readable, H: Readable, I: Readable, J: Readable, K: Readable> Readable for (A, B, C, D, E, F, G, H, I, J, K)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable, G: Readable, H: Readable, I: Readable, J: Readable> Readable for (A, B, C, D, E, F, G, H, I, J)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable, G: Readable, H: Readable, I: Readable> Readable for (A, B, C, D, E, F, G, H, I)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable, G: Readable, H: Readable> Readable for (A, B, C, D, E, F, G, H)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable, G: Readable> Readable for (A, B, C, D, E, F, G)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable, F: Readable> Readable for (A, B, C, D, E, F)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable, E: Readable> Readable for (A, B, C, D, E)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable, D: Readable> Readable for (A, B, C, D)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable, C: Readable> Readable for (A, B, C)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable, B: Readable> Readable for (A, B)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<A: Readable> Readable for (A,)

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<K, V, S> Readable for HashMap<K, V, S>
where K: Readable + Eq + Hash, V: Readable, S: BuildHasher + Default,

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<K: Readable + Ord, V: Readable> Readable for BTreeMap<K, V>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T, S> Readable for HashSet<T, S>
where T: Readable + Eq + Hash, S: BuildHasher + Default,

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T: Readable + Ord> Readable for BTreeSet<T>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T: Readable> Readable for Bound<T>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T: Readable> Readable for LinkedList<T>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T: Readable> Readable for Option<T>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T: Readable> Readable for Vec<T>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<T: Readable> Readable for VecDeque<T>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Source§

impl<V: Readable, E: Readable> Readable for Result<V, E>

Source§

fn read_from(reader: &mut (impl Read + ?Sized)) -> Result<Self, ReadableError>

Implementors§