Struct dbn::record_ref::RecordRef
source · pub struct RecordRef<'a> { /* private fields */ }Expand description
A wrapper around a non-owning immutable reference to a DBN record. This wrapper allows for mixing of record types and schemas, and runtime record polymorphism.
Implementations§
source§impl<'a> RecordRef<'a>
impl<'a> RecordRef<'a>
sourcepub unsafe fn new(buffer: &'a [u8]) -> Self
pub unsafe fn new(buffer: &'a [u8]) -> Self
Constructs a new reference to the DBN record in buffer.
Safety
buffer should begin with a RecordHeader and contain a type implementing
HasRType.
sourcepub unsafe fn unchecked_from_header(header: *const RecordHeader) -> Self
pub unsafe fn unchecked_from_header(header: *const RecordHeader) -> Self
sourcepub fn header(&self) -> &RecordHeader
pub fn header(&self) -> &RecordHeader
Returns a reference to the RecordHeader of the referenced record.
sourcepub fn has<T: HasRType>(&self) -> bool
pub fn has<T: HasRType>(&self) -> bool
Returns true if the object points to a record of type T.
sourcepub fn record_size(&self) -> usize
pub fn record_size(&self) -> usize
Returns the size of the record in bytes.
sourcepub fn get<T: HasRType>(&self) -> Option<&'a T>
pub fn get<T: HasRType>(&self) -> Option<&'a T>
Returns a reference to the underlying record of type T or None if it points
to another record type.
Note: for safety, this method calls has::<T>(). To avoid a
duplicate check, use get_unchecked().
Trait Implementations§
impl Send for RecordRef<'_>
impl Sync for RecordRef<'_>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for RecordRef<'a>
impl<'a> Unpin for RecordRef<'a>
impl<'a> UnwindSafe for RecordRef<'a>
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