object_rainbow/impls/
u8.rs

1use typenum::U1;
2
3use crate::*;
4
5impl ToOutput for u8 {
6    fn to_output(&self, output: &mut dyn crate::Output) {
7        output.write(&[*self]);
8    }
9
10    fn slice_to_output(slice: &[Self], output: &mut dyn crate::Output)
11    where
12        Self: Sized,
13    {
14        output.write(slice);
15    }
16}
17
18impl<I: ParseInput> Parse<I> for u8 {
19    fn parse(input: I) -> crate::Result<Self> {
20        ParseInline::parse_as_inline(input)
21    }
22}
23
24impl<I: ParseInput> ParseInline<I> for u8 {
25    fn parse_inline(input: &mut I) -> crate::Result<Self> {
26        Ok(Self::from_le_bytes(*input.parse_chunk::<1>()?))
27    }
28
29    fn parse_vec(input: I) -> crate::Result<Vec<Self>> {
30        Ok(input.parse_all()?.into())
31    }
32}
33
34impl Size for u8 {
35    type Size = U1;
36    const SIZE: usize = 1;
37}
38
39impl MaybeHasNiche for u8 {
40    type MnArray = NoNiche<ZeroNoNiche<<Self as Size>::Size>>;
41}
42
43impl Tagged for u8 {}
44impl<E: 'static> Topological<E> for u8 {}
45impl<E: 'static> Object<E> for u8 {}
46impl<E: 'static> Inline<E> for u8 {}
47impl ReflessObject for u8 {}
48impl ReflessInline for u8 {}