#[non_exhaustive]pub struct FetchConfig {
pub cache_dir: PathBuf,
pub endpoint: String,
pub token: Option<String>,
pub offline: bool,
}Expand description
Where and how the fetcher reads and downloads.
§Example
use std::collections::HashMap;
use adk_vision::FetchConfig;
let env: HashMap<&str, &str> =
[("HF_HOME", "/data/hf"), ("HF_HUB_OFFLINE", "1"), ("HF_TOKEN", "hf_x")].into();
let config = FetchConfig::from_lookup(|key| env.get(key).map(|v| v.to_string()));
assert_eq!(config.cache_dir, std::path::PathBuf::from("/data/hf/hub"));
assert!(config.offline);
assert_eq!(config.token.as_deref(), Some("hf_x"));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.cache_dir: PathBufThe hub cache: HF_HUB_CACHE, else $HF_HOME/hub, else ~/.cache/huggingface/hub.
endpoint: StringThe hub endpoint: HF_ENDPOINT, else https://huggingface.co.
token: Option<String>The access token: HF_TOKEN.
offline: boolHF_HUB_OFFLINE is 1, true, yes or on: no socket is opened.
Implementations§
Source§impl FetchConfig
impl FetchConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
The configuration from the process environment, by Python’s huggingface_hub
conventions; the hf-hub crate reads none of them itself.
Sourcepub fn from_lookup(lookup: impl Fn(&str) -> Option<String>) -> Self
pub fn from_lookup(lookup: impl Fn(&str) -> Option<String>) -> Self
The configuration from a variable lookup.
Sourcepub fn with_cache_dir(self, dir: impl Into<PathBuf>) -> Self
pub fn with_cache_dir(self, dir: impl Into<PathBuf>) -> Self
Uses dir as the hub cache.
Sourcepub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
pub fn with_endpoint(self, endpoint: impl Into<String>) -> Self
Downloads from endpoint.
Sourcepub fn with_offline(self, offline: bool) -> Self
pub fn with_offline(self, offline: bool) -> Self
Sets offline mode.
Sourcepub fn with_token(self, token: Option<String>) -> Self
pub fn with_token(self, token: Option<String>) -> Self
Sets the access token.
Trait Implementations§
Source§impl Clone for FetchConfig
impl Clone for FetchConfig
Source§impl Debug for FetchConfig
impl Debug for FetchConfig
impl Eq for FetchConfig
Source§impl PartialEq for FetchConfig
impl PartialEq for FetchConfig
impl StructuralPartialEq for FetchConfig
Auto Trait Implementations§
impl Forget for FetchConfig
impl Freeze for FetchConfig
impl Move for FetchConfig
impl RefUnwindSafe for FetchConfig
impl Send for FetchConfigwhere
RawVecInner: Send,
impl Sync for FetchConfigwhere
RawVecInner: Sync,
impl Unpin for FetchConfig
impl UnsafeUnpin for FetchConfig
impl UnwindSafe for FetchConfigwhere
RawVecInner: UnwindSafe,
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
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.impl<T> ErasedDestructor for Twhere
T: 'static,
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 moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSend for Twhere
T: Send,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.