pub struct Layer<'l, Stream: Write + Read + Seek> {
pub bounds: Option<Range<u64>>,
pub size: u64,
pub read_cursor: (u64, usize),
/* private fields */
}
Expand description
Represents a layer (either in the heap or disk) in the stack-db that stacks
Fields§
§bounds: Option<Range<u64>>
The bounds of the layer; the range of the layer
size: u64
The total size of all the writes in the layer
read_cursor: (u64, usize)
The current read cursor to speed up sequential reads
Implementations§
Source§impl<'l, Stream: Write + Read + Seek> Layer<'l, Stream>
impl<'l, Stream: Write + Read + Seek> Layer<'l, Stream>
pub fn new(stream: Stream) -> Self
pub fn load(stream: Stream) -> Result<Self, Error>
Sourcepub fn check_collisions(
&mut self,
range: &Range<u64>,
) -> Result<Box<[Range<u64>]>, Error>
pub fn check_collisions( &mut self, range: &Range<u64>, ) -> Result<Box<[Range<u64>]>, Error>
Checks for collisions on the current layer
Sourcepub fn check_non_collisions(
&self,
range: &Range<u64>,
collisions: &[Range<u64>],
) -> Box<[Range<u64>]>
pub fn check_non_collisions( &self, range: &Range<u64>, collisions: &[Range<u64>], ) -> Box<[Range<u64>]>
Takes in the ordered output of the check_collisions
function to find the inverse
Sourcepub fn read_unchecked(
&mut self,
addr: &Range<u64>,
) -> Result<(Range<usize>, Cow<'_, [u8]>), Error>
pub fn read_unchecked( &mut self, addr: &Range<u64>, ) -> Result<(Range<usize>, Cow<'_, [u8]>), Error>
Reads from the layer unchecked and returns the section data and the desired relative range within the section.
warning: will throw out-of-bounds
error (or undefined behaviour) if the read is accross two sections (each read can only be on one section of a layer)
Trait Implementations§
Auto Trait Implementations§
impl<'l, Stream> Freeze for Layer<'l, Stream>where
Stream: Freeze,
impl<'l, Stream> RefUnwindSafe for Layer<'l, Stream>where
Stream: RefUnwindSafe,
impl<'l, Stream> Send for Layer<'l, Stream>where
Stream: Send,
impl<'l, Stream> Sync for Layer<'l, Stream>where
Stream: Sync,
impl<'l, Stream> Unpin for Layer<'l, Stream>where
Stream: Unpin,
impl<'l, Stream> UnwindSafe for Layer<'l, Stream>where
Stream: UnwindSafe,
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