Skip to main content

le_stream/
to_le_stream.rs

1mod alloc;
2mod core;
3mod heapless;
4mod intx;
5mod macaddr;
6
7/// Converts a value into a stream of little-endian bytes.
8///
9/// The returned iterator yields the complete byte representation of `self`.
10/// Primitive numeric implementations use their standard little-endian byte
11/// order; compound implementations concatenate the byte stream of each field or
12/// element in declaration order.
13pub trait ToLeStream
14where
15    Self::Iter: Iterator<Item = u8>,
16{
17    /// Iterator returned by [`to_le_stream`](Self::to_le_stream).
18    type Iter;
19
20    /// Returns an iterator over the little-endian byte representation.
21    ///
22    /// # Examples
23    ///
24    /// ```
25    /// use le_stream::ToLeStream;
26    ///
27    /// assert_eq!(0x1234_u16.to_le_stream().collect::<Vec<_>>(), [0x34, 0x12]);
28    /// ```
29    fn to_le_stream(self) -> Self::Iter;
30}