Struct rust_bert::resources::RemoteResource
source · pub struct RemoteResource {
pub url: String,
pub cache_subdir: String,
}Expand description
Fields§
§url: StringRemote path/url for the resource
cache_subdir: StringLocal subdirectory of the cache root where this resource is saved
Implementations§
source§impl RemoteResource
impl RemoteResource
sourcepub fn new(url: &str, cache_subdir: &str) -> RemoteResource
pub fn new(url: &str, cache_subdir: &str) -> RemoteResource
Creates a new RemoteResource from an URL and a custom local path. Note that this does not download the resource (only declares the remote and local locations)
Arguments
url-&strLocation of the remote resourcecache_subdir-&strLocal subdirectory of the cache root to save the resource to
Returns
RemoteResourceRemoteResource object
Example
use rust_bert::resources::RemoteResource;
let config_resource = RemoteResource::new("http://config_json_location", "configs");sourcepub fn from_pretrained(name_url_tuple: (&str, &str)) -> RemoteResource
pub fn from_pretrained(name_url_tuple: (&str, &str)) -> RemoteResource
Creates a new RemoteResource from an URL and local name. Will define a local path pointing to ~/.cache/.rustbert/model_name. Note that this does not download the resource (only declares the remote and local locations)
Arguments
name_url_tuple-(&str, &str)Location of the name of model and remote resource
Returns
RemoteResourceRemoteResource object
Example
use rust_bert::resources::RemoteResource;
let model_resource = RemoteResource::from_pretrained((
"distilbert-sst2",
"https://huggingface.co/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/rust_model.ot",
));Trait Implementations§
source§impl Clone for RemoteResource
impl Clone for RemoteResource
source§fn clone(&self) -> RemoteResource
fn clone(&self) -> RemoteResource
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for RemoteResource
impl Debug for RemoteResource
source§impl PartialEq<RemoteResource> for RemoteResource
impl PartialEq<RemoteResource> for RemoteResource
source§fn eq(&self, other: &RemoteResource) -> bool
fn eq(&self, other: &RemoteResource) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl ResourceProvider for RemoteResource
impl ResourceProvider for RemoteResource
source§fn get_local_path(&self) -> Result<PathBuf, RustBertError>
fn get_local_path(&self) -> Result<PathBuf, RustBertError>
Gets the local path for a remote resource.
The remote resource is downloaded and cached. Then the path to the local cache is returned.
Returns
PathBufpointing 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>
fn get_resource(&self) -> Result<Resource<'_>, RustBertError>
Gets a wrapper around the local path for a remote resource.
Returns
Resourcewrapping aPathBufpointing to the resource file
Example
use rust_bert::resources::{RemoteResource, ResourceProvider};
let config_resource = RemoteResource::new("http://config_json_location", "configs");
let config_path = config_resource.get_resource();impl Eq for RemoteResource
impl StructuralEq for RemoteResource
impl StructuralPartialEq for RemoteResource
Auto Trait Implementations§
impl RefUnwindSafe for RemoteResource
impl Send for RemoteResource
impl Sync for RemoteResource
impl Unpin for RemoteResource
impl UnwindSafe for RemoteResource
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
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.