Struct flatdata::MemoryResourceStorage
source · pub struct MemoryResourceStorage { /* private fields */ }
Expand description
Resource storage in memory.
Used to create and read archives from memory, e.g. for writing tests.
Examples
use flatdata::{MemoryResourceStorage, Vector};
use flatdata::test::{X, XBuilder};
let storage = MemoryResourceStorage::new("/root/to/my/archive/in/memory");
let builder = XBuilder::new(storage.clone()).expect("failed to create builder");
// Write some data and store it archive, e.g.
let v = Vector::new();
builder.set_data(&v.as_view());
let archive = X::open(storage).expect("failed to open");
// read data
archive.data();
Implementations§
Trait Implementations§
source§impl Debug for MemoryResourceStorage
impl Debug for MemoryResourceStorage
source§impl ResourceStorage for MemoryResourceStorage
impl ResourceStorage for MemoryResourceStorage
source§fn subdir(&self, dir: &str) -> StorageHandle
fn subdir(&self, dir: &str) -> StorageHandle
Creates a resource storage at a given subdirectory.
source§fn read_resource(&self, resource_name: &str) -> Result<&[u8], Error>
fn read_resource(&self, resource_name: &str) -> Result<&[u8], Error>
Reads a resource in storage and returns a pointer to its raw data. Read more
source§fn create_output_stream(
&self,
resource_name: &str
) -> Result<Box<dyn Stream>, Error>
fn create_output_stream( &self, resource_name: &str ) -> Result<Box<dyn Stream>, Error>
Creates a resource with given name and returns an output stream for
writing to it.
source§fn read(
&self,
resource_name: &str,
schema: &str
) -> Result<&[u8], ResourceStorageError>
fn read( &self, resource_name: &str, schema: &str ) -> Result<&[u8], ResourceStorageError>
Open a flatdata resource with given name and schema for reading. Read more
source§fn write(&self, resource_name: &str, schema: &str, data: &[u8]) -> Result<()>
fn write(&self, resource_name: &str, schema: &str, data: &[u8]) -> Result<()>
Writes data of a flatdata resource with given name and schema to
storage. Read more
source§fn read_and_check_schema(
&self,
resource_name: &str,
expected_schema: &str
) -> Result<&[u8], ResourceStorageError>
fn read_and_check_schema( &self, resource_name: &str, expected_schema: &str ) -> Result<&[u8], ResourceStorageError>
Auto Trait Implementations§
impl RefUnwindSafe for MemoryResourceStorage
impl Send for MemoryResourceStorage
impl Sync for MemoryResourceStorage
impl Unpin for MemoryResourceStorage
impl UnwindSafe for MemoryResourceStorage
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