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