pub unsafe trait Allocator: DerefMut<Target = [u8]> {
type Error: Display + Debug;
// Required methods
fn grow_downwards(&mut self) -> Result<(), Self::Error>;
fn len(&self) -> usize;
}
Expand description
Trait to implement custom allocation strategies for FlatBufferBuilder
.
An implementation can be used with FlatBufferBuilder::new_in
, enabling a custom allocation
strategy for the FlatBufferBuilder
.
§Safety
The implementation of the allocator must match the defined behavior as described by the comments.
Required Associated Types§
Required Methods§
Sourcefn grow_downwards(&mut self) -> Result<(), Self::Error>
fn grow_downwards(&mut self) -> Result<(), Self::Error>
Grows the buffer, with the old contents being moved to the end.
NOTE: While not unsound, an implementation that doesn’t grow the internal buffer will get stuck in an infinite loop.