pub struct XetConfig {
pub endpoint: String,
pub token: Option<String>,
pub compression: Option<CompressionScheme>,
}Expand description
Configuration for XET large file storage
Fields§
§endpoint: StringCAS endpoint URL
Can be set via:
GIT2DB_XET_ENDPOINTenvironment variableXETHUB_ENDPOINTenvironment variable- Programmatic configuration
If empty, XET is disabled.
token: Option<String>Authentication token
Resolved in priority order:
XETHUB_TOKENenvironment variableHF_TOKENenvironment variable- HuggingFace CLI token file (
~/.cache/huggingface/token)
compression: Option<CompressionScheme>Compression scheme
Implementations§
Source§impl XetConfig
impl XetConfig
Sourcepub fn new(endpoint: impl Into<String>) -> Self
pub fn new(endpoint: impl Into<String>) -> Self
Create a new XET configuration with the given endpoint
Sourcepub fn huggingface() -> Self
pub fn huggingface() -> Self
Create a configuration for HuggingFace repositories
Uses the HuggingFace XET endpoint and automatically picks up
authentication from HF_TOKEN or XETHUB_TOKEN environment variables.
Sourcepub fn is_huggingface(&self) -> bool
pub fn is_huggingface(&self) -> bool
Check if this configuration is for HuggingFace
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if XET is enabled (endpoint is not empty)
Sourcepub fn with_token(self, token: impl Into<String>) -> Self
pub fn with_token(self, token: impl Into<String>) -> Self
Set the authentication token
Sourcepub fn with_compression(self, compression: CompressionScheme) -> Self
pub fn with_compression(self, compression: CompressionScheme) -> Self
Set the compression scheme
Sourcepub fn for_url(url: &str) -> Option<Self>
pub fn for_url(url: &str) -> Option<Self>
Create XET config appropriate for a git URL
Resolution order:
- Environment variable (XETHUB_ENDPOINT/GIT2DB_XET_ENDPOINT) - always takes priority
- URL pattern matching - convenience for known providers
- None - XET disabled for this URL
§Examples
ⓘ
// With env var set, always uses that endpoint
std::env::set_var("XETHUB_ENDPOINT", "https://my.xet.server");
let config = XetConfig::for_url("https://github.com/any/repo");
assert!(config.is_some());
// Without env var, uses URL pattern matching
std::env::remove_var("XETHUB_ENDPOINT");
let config = XetConfig::for_url("https://hf.co/Qwen/Qwen3-0.6B");
assert!(config.unwrap().is_huggingface());
// Unknown URL with no env var = None
let config = XetConfig::for_url("https://github.com/unknown/repo");
assert!(config.is_none());Sourcepub fn is_ssh_transport(&self) -> bool
pub fn is_ssh_transport(&self) -> bool
Check if the endpoint uses SSH transport
Sourcepub fn is_https_transport(&self) -> bool
pub fn is_https_transport(&self) -> bool
Check if the endpoint uses HTTPS transport
Sourcepub async fn create_storage(&self) -> Result<Box<dyn StorageBackend>>
pub async fn create_storage(&self) -> Result<Box<dyn StorageBackend>>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for XetConfig
impl<'de> Deserialize<'de> for XetConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for XetConfig
impl RefUnwindSafe for XetConfig
impl Send for XetConfig
impl Sync for XetConfig
impl Unpin for XetConfig
impl UnsafeUnpin for XetConfig
impl UnwindSafe for XetConfig
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
fn map_response_body<F>(self, f: F) -> MapResponseBody<Self, F>where
Self: Sized,
Apply a transformation to the response body. Read more
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using HTTP status codes. Read more
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
High level tracing that classifies responses using gRPC headers. Read more