object_rainbow/impls/
u8.rs1use 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
11impl InlineOutput for u8 {
12 fn slice_to_output(slice: &[Self], output: &mut dyn crate::Output)
13 where
14 Self: Sized,
15 {
16 output.write(slice);
17 }
18}
19
20impl<I: ParseInput> Parse<I> for u8 {
21 fn parse(input: I) -> crate::Result<Self> {
22 ParseInline::parse_as_inline(input)
23 }
24}
25
26impl<I: ParseInput> ParseInline<I> for u8 {
27 fn parse_inline(input: &mut I) -> crate::Result<Self> {
28 Ok(Self::from_le_bytes(*input.parse_chunk::<1>()?))
29 }
30
31 fn parse_vec(input: I) -> crate::Result<Vec<Self>> {
32 Ok(input.parse_all()?.into())
33 }
34
35 fn parse_array<const N: usize>(input: &mut I) -> crate::Result<[Self; N]> {
36 input.parse_chunk().copied()
37 }
38}
39
40impl Size for u8 {
41 type Size = U1;
42 const SIZE: usize = 1;
43}