Trait ResourceProvider

Source
pub trait ResourceProvider:
    Debug
    + Send
    + Sync {
    // Required methods
    fn get_local_path(&self) -> Result<PathBuf, RustBertError>;
    fn get_resource(&self) -> Result<Resource<'_>, RustBertError>;
}
Expand description

§Resource Trait that can provide the location or data for the model, and location of

configuration or vocabulary resources

Required Methods§

Source

fn get_local_path(&self) -> Result<PathBuf, RustBertError>

Provides the local path for a resource.

§Returns
  • PathBuf pointing to the resource file
§Example
use rust_bert::resources::{LocalResource, ResourceProvider};
use std::path::PathBuf;
let config_resource = LocalResource {
    local_path: PathBuf::from("path/to/config.json"),
};
let config_path = config_resource.get_local_path();
Source

fn get_resource(&self) -> Result<Resource<'_>, RustBertError>

Provides access to an underlying resource.

§Returns
  • Resource wrapping a representation of a resource.
§Example
use rust_bert::resources::{BufferResource, LocalResource, ResourceProvider};

Trait Implementations§

Source§

impl From<PathBuf> for Box<dyn ResourceProvider + Send>

Source§

fn from(local_path: PathBuf) -> Self

Converts to this type from the input type.
Source§

impl From<RwLock<Vec<u8>>> for Box<dyn ResourceProvider>

Source§

fn from(lock: RwLock<Vec<u8>>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Box<dyn ResourceProvider>

Source§

fn from(data: Vec<u8>) -> Self

Converts to this type from the input type.

Implementations on Foreign Types§

Source§

impl<T: ResourceProvider + ?Sized> ResourceProvider for Box<T>

Implementors§