Struct Page

Source
pub struct Page { /* private fields */ }
Expand description

Page is a wrapper for a single page of memory providing some helpful helpers for quick access.

Implementations§

Source§

impl Page

Source

pub fn new(data: [u8; 4096]) -> Page

Source

pub fn write_value_at_offset( &mut self, offset: usize, value: usize, ) -> Result<(), Error>

write_value_at_offset writes a given value (as BigEndian) at a certain offset overriding values at that offset.

Source

pub fn get_value_from_offset(&self, offset: usize) -> Result<usize, Error>

get_value_from_offset Fetches a value calculated as BigEndian, sized to usize. This function may error as the value might not fit into a usize.

Source

pub fn insert_bytes_at_offset( &mut self, bytes: &[u8], offset: usize, end_offset: usize, size: usize, ) -> Result<(), Error>

insert_bytes_at_offset pushes #size bytes from offset to end_offset inserts #size bytes from given slice.

Source

pub fn write_bytes_at_offset( &mut self, bytes: &[u8], offset: usize, size: usize, ) -> Result<(), Error>

write_bytes_at_offset write bytes at a certain offset overriding previous values.

Source

pub fn get_ptr_from_offset(&self, offset: usize, size: usize) -> &[u8]

get_ptr_from_offset Fetches a slice of bytes from certain offset and of certain size.

Source

pub fn get_data(&self) -> [u8; 4096]

get_data returns the underlying array.

Trait Implementations§

Source§

impl TryFrom<&Node> for Page

Implement TryFrom<Box> for Page allowing for easier serialization of data from a Node to an on-disk formatted page.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(node: &Node) -> Result<Page, Error>

Performs the conversion.
Source§

impl TryFrom<Page> for Node

Implement TryFrom for Node allowing for easier deserialization of data from a Page.

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

fn try_from(page: Page) -> Result<Node, Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Page

§

impl RefUnwindSafe for Page

§

impl Send for Page

§

impl Sync for Page

§

impl Unpin for Page

§

impl UnwindSafe for Page

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.