bitcode/
u8_char.rs
1use crate::coder::{Buffer, Encoder};
2use crate::derive::Encode;
3use crate::fast::VecImpl;
4use alloc::vec::Vec;
5use core::num::NonZeroUsize;
6
7#[derive(Copy, Clone)]
9#[repr(transparent)]
10pub struct U8Char(pub u8);
11
12unsafe impl bytemuck::Zeroable for U8Char {}
14unsafe impl bytemuck::Pod for U8Char {}
15
16impl Encode for U8Char {
17 type Encoder = U8CharEncoder;
18}
19
20#[derive(Default)]
21pub struct U8CharEncoder(VecImpl<U8Char>);
22
23impl Encoder<U8Char> for U8CharEncoder {
24 #[inline(always)]
25 fn as_primitive(&mut self) -> Option<&mut VecImpl<U8Char>> {
26 Some(&mut self.0)
27 }
28
29 #[inline(always)]
30 fn encode(&mut self, _: &U8Char) {
31 unimplemented!(); }
33}
34
35impl Buffer for U8CharEncoder {
36 fn collect_into(&mut self, out: &mut Vec<u8>) {
37 out.extend_from_slice(bytemuck::must_cast_slice(self.0.as_slice()));
38 self.0.clear();
39 }
40
41 fn reserve(&mut self, _: NonZeroUsize) {
42 unimplemented!(); }
44}