1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
//! Miscellaneous traits and types.

/// A type whose instance may be contained in some value.
pub trait Contained<T> {
    /// Returns whether `self` is contained in `other`.
    fn contained_in(self, other: T) -> bool;
}

/// A type whose instances may be used to extract references from buffers.
///
/// All operations are non-panicking and cannot fail.
pub trait Extract<T: ?Sized> {
    /// The output type.
    type Output: ?Sized;

    /// Extracts a reference to the value for `self` within `buf`.
    fn extract<'a>(self, buf: &'a T) -> &'a Self::Output;

    /// Extracts a mutable reference to the value for `self` within `buf`.
    fn extract_mut<'a>(self, buf: &'a mut T) -> &'a mut Self::Output;
}