pub trait Factory<Trait: ArchiveTrait + ?Sized>: Send + Sync {
// Required methods
fn size_of(&self) -> usize;
fn default_box(&self) -> Box<Trait>;
fn with(&self, f: &mut dyn FnMut(&mut Trait));
unsafe fn archived_value<'a>(
&self,
bytes: &'a [u8],
pos: usize,
) -> &'a Trait::Archived;
// Provided method
fn is_zst(&self) -> bool { ... }
}Expand description
Create instances of a concrete type wrapped in a trait object.
Required Methods§
Sourcefn default_box(&self) -> Box<Trait>
fn default_box(&self) -> Box<Trait>
Create an instance of the underlying concrete type with the default value on the heap.
Sourcefn with(&self, f: &mut dyn FnMut(&mut Trait))
fn with(&self, f: &mut dyn FnMut(&mut Trait))
Creates an instance of the underlying concrete type with the default value on the stack and passes it as an argument to the provided closure.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".