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

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§