pub struct RemoteResource {
pub url: String,
pub cache_subdir: String,
}Expand description
§Remote resource that will be downloaded and cached locally on demand
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 for RemoteResource
impl PartialEq for RemoteResource
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 StructuralPartialEq for RemoteResource
Auto Trait Implementations§
impl Freeze for RemoteResource
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more