#![warn(missing_docs)]
#![doc = include_str!("../README.md")]
use std::mem::MaybeUninit;
mod impls;
mod scalar_contents;
pub use scalar_contents::ScalarContents;
mod shape;
pub use shape::*;
mod slot;
pub use slot::Slot;
mod partial;
pub use partial::*;
mod helpers;
pub use helpers::*;
pub mod mini_typeid;
#[doc(hidden)]
pub mod log;
pub use log::*;
#[cfg(test)]
mod tests;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Bytes(pub Vec<u8>);
impl Shapely for Bytes {
fn shape() -> Shape {
Shape {
name: |f, _opts| write!(f, "Bytes"),
typeid: mini_typeid::of::<Self>(),
layout: std::alloc::Layout::new::<Self>(),
innards: Innards::Scalar(Scalar::Bytes),
set_to_default: Some(|addr: *mut u8| unsafe {
*(addr as *mut Bytes) = Bytes(Vec::new());
}),
drop_in_place: Some(|addr: *mut u8| unsafe {
std::ptr::drop_in_place(addr as *mut Bytes);
}),
}
}
}
pub trait Shapely: Sized {
fn shape() -> Shape;
fn shape_desc() -> ShapeDesc {
ShapeDesc(Self::shape)
}
fn partial() -> Partial<'static> {
Partial::alloc(Self::shape_desc())
}
fn partial_from_uninit(dest: &mut MaybeUninit<Self>) -> Partial<'_> {
Partial::borrow(dest)
}
}