Enum biome_formatter::BufferSnapshot
source · pub enum BufferSnapshot {
Position(usize),
Any(Box<dyn Any>),
}
Expand description
Snapshot of a buffer state that can be restored at a later point.
Used in cases where the formatting of an object fails but a parent formatter knows an alternative strategy on how to format the object that might succeed.
Variants§
Position(usize)
Stores an absolute position of a buffers state, for example, the offset of the last written element.
Any(Box<dyn Any>)
Generic structure for custom buffers that need to store more complex data. Slightly more expensive because it requires allocating the buffer state on the heap.
Implementations§
source§impl BufferSnapshot
impl BufferSnapshot
sourcepub const fn position(index: usize) -> Self
pub const fn position(index: usize) -> Self
Creates a new buffer snapshot that points to the specified position.
sourcepub fn unwrap_position(&self) -> usize
pub fn unwrap_position(&self) -> usize
sourcepub fn unwrap_any<T: 'static>(self) -> T
pub fn unwrap_any<T: 'static>(self) -> T
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferSnapshot
impl !RefUnwindSafe for BufferSnapshot
impl !Send for BufferSnapshot
impl !Sync for BufferSnapshot
impl Unpin for BufferSnapshot
impl !UnwindSafe for BufferSnapshot
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more