pub unsafe trait Emit<T>: Sized {
// Required method
unsafe fn write_at(self, p: &mut impl Patch, at: Pos);
// Provided method
fn emit(self, p: &mut impl Patch) -> Pos
where T: Flat { ... }
}Expand description
Builder trait for constructing values in a Region.
Implementors describe how to serialize a value of type T into a region buffer.
The #[derive(Flat)] macro generates builder types (e.g. Foo::make(...))
that implement this trait, enabling fully declarative, tree-shaped region
construction via Region::new.
§Safety
Implementations must correctly write exactly size_of::<T>() bytes at the given
position, with correct field offsets and pointer patching. This invariant is upheld
by the derive macro; manual implementations must ensure the same.
§Key implementations
| Type | Behavior |
|---|---|
Primitives (u32, bool, …) | Self-emit via write_flat |
&T where T: Flat | Deep-copy via Flat::deep_copy (blanket impl) |
Ref<'id, T> | Deep-copy from existing buffer position |
Infallible | Unreachable (used for empty NearList iterators) |
| Generated builders | Field-by-field construction with pointer patching |
Required Methods§
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.