1use std::mem::MaybeUninit;
2
3mod hashmap_impl;
4mod scalar_impls;
5
6mod scalar_contents;
7pub use scalar_contents::ScalarContents;
8
9mod shape;
10pub use shape::*;
11
12mod slot;
13pub use slot::Slot;
14
15mod partial;
16pub use partial::*;
17
18mod helpers;
19pub use helpers::*;
20
21pub mod mini_typeid;
22
23#[doc(hidden)]
24pub mod log;
25pub use log::*;
26
27#[cfg(test)]
28mod tests;
29
30#[cfg(test)]
31mod scalar_contents_tests;
32
33#[derive(Debug, Clone, PartialEq, Eq)]
35pub struct Bytes(pub Vec<u8>);
36
37impl Shapely for Bytes {
38 fn shape() -> Shape {
39 Shape {
40 name: |f| write!(f, "Bytes"),
41 typeid: mini_typeid::of::<Self>(),
42 layout: std::alloc::Layout::new::<Self>(),
43 innards: Innards::Scalar(Scalar::Bytes),
44 set_to_default: Some(|addr: *mut u8| unsafe {
45 *(addr as *mut Bytes) = Bytes(Vec::new());
46 }),
47 drop_in_place: Some(|addr: *mut u8| unsafe {
48 std::ptr::drop_in_place(addr as *mut Bytes);
49 }),
50 }
51 }
52}
53
54pub trait Shapely: Sized {
57 fn shape() -> Shape;
59
60 fn shape_desc() -> ShapeDesc {
62 ShapeDesc(Self::shape)
63 }
64
65 fn partial() -> Partial<'static> {
67 Partial::alloc(Self::shape_desc())
68 }
69
70 fn partial_from_uninit(dest: &mut MaybeUninit<Self>) -> Partial<'_> {
74 Partial::borrow(dest)
75 }
76
77 }