Struct XetConfig
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§
§impl XetConfig
impl XetConfig
pub fn new(endpoint: impl Into<String>) -> XetConfig
pub fn new(endpoint: impl Into<String>) -> XetConfig
Create a new XET configuration with the given endpoint
pub fn huggingface() -> XetConfig
pub fn huggingface() -> XetConfig
Create a configuration for HuggingFace repositories
Uses the HuggingFace XET endpoint and automatically picks up
authentication from HF_TOKEN or XETHUB_TOKEN environment variables.
pub fn is_huggingface(&self) -> bool
pub fn is_huggingface(&self) -> bool
Check if this configuration is for HuggingFace
pub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if XET is enabled (endpoint is not empty)
pub fn with_token(self, token: impl Into<String>) -> XetConfig
pub fn with_token(self, token: impl Into<String>) -> XetConfig
Set the authentication token
pub fn with_compression(self, compression: CompressionScheme) -> XetConfig
pub fn with_compression(self, compression: CompressionScheme) -> XetConfig
Set the compression scheme
pub fn for_url(url: &str) -> Option<XetConfig>
pub fn for_url(url: &str) -> Option<XetConfig>
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());pub fn is_ssh_transport(&self) -> bool
pub fn is_ssh_transport(&self) -> bool
Check if the endpoint uses SSH transport
pub fn is_https_transport(&self) -> bool
pub fn is_https_transport(&self) -> bool
Check if the endpoint uses HTTPS transport
pub async fn create_storage(&self) -> Result<Box<dyn StorageBackend>, XetError>
pub async fn create_storage(&self) -> Result<Box<dyn StorageBackend>, XetError>
Trait Implementations§
§impl<'de> Deserialize<'de> for XetConfig
impl<'de> Deserialize<'de> for XetConfig
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<XetConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<XetConfig, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Serialize for XetConfig
impl Serialize for XetConfig
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. 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