Trait flatdata::ResourceStorage[][src]

pub trait ResourceStorage {
    fn subdir(&self, dir: &str) -> Rc<RefCell<ResourceStorage>>;
fn exists(&self, resource_name: &str) -> bool;
fn read_resource(
        &mut self,
        resource_name: &str
    ) -> Result<MemoryDescriptor, Error>;
fn create_output_stream(
        &mut self,
        resource_name: &str
    ) -> Result<Rc<RefCell<Stream>>>; fn read(
        &mut self,
        resource_name: &str,
        schema: &str
    ) -> Result<MemoryDescriptor, ResourceStorageError> { ... }
fn write(
        &mut self,
        resource_name: &str,
        schema: &str,
        data: &[u8]
    ) -> Result<()> { ... }
fn read_and_check_schema(
        &mut self,
        resource_name: &str,
        expected_schema: &str
    ) -> Result<MemoryDescriptor, ResourceStorageError> { ... } }

Hierarchical Resource Storage

Manages and returns resources corresponding to their keys. Keys can be slash-separated('/'). Manages schema for each resource and checks it on query. Resource storage is expected to provide read-write access to resources.

Required Methods

Creates a resource storage at a given subdirectory.

Returns true if resource exists in the storage.

Reads a resource in storage and returns a pointer to its raw data.

This is a low level facility for opening and reading resources. Cf. read for opening flatdata resources and checking the corresponding schema.

Creates a resource with given name and returns an output stream for writing to it.

Provided Methods

Open a flatdata resource with given name and schema for reading.

Also checks if the schema matches the stored schema in the storage. The schema is expected to be stored in the storage as another resource with name {resource_name}.schema.

Writes data of a flatdata resource with given name and schema to storage.

The schema will be stored as another resource under the name {resource_name}.schema.

Implementation helper for read.

Uses the required method read_resource for open the corresponding resource and its schema. It checks the integrity of data by verifying that the size of resource matched the size specified in the header. Also checks that the stored schema matches the provided schema.

Implementors