hf-hub
hf-hub copied to clipboard
When will sync::Api::new() return an Result::Err()?
I try to handle the Error that Api::new() may return, but it seems that it never returns a error. Here's the related code in latest commit 6303587576f8a1ce9f91f8274265a153b89afb6e
:
// src/api/sync.rs
impl Api {
/// Creates a default Api, for Api options See [`ApiBuilder`]
pub fn new() -> Result<Self, ApiError> {
ApiBuilder::new().build()
}
// ...
}
// src/api/sync.rs
impl ApiBuilder {
//...
/// Consumes the builder and buids the final [`Api`]
pub fn build(self) -> Result<Api, ApiError> {
let headers = self.build_headers();
let agent = ureq::builder().try_proxy_from_env(true).build();
let client = HeaderAgent::new(agent, headers.clone());
let no_redirect_agent = ureq::builder()
.try_proxy_from_env(true)
.redirects(0)
.build();
let no_redirect_client = HeaderAgent::new(no_redirect_agent, headers);
Ok(Api {
endpoint: self.endpoint,
url_template: self.url_template,
cache: self.cache,
client,
no_redirect_client,
progress: self.progress,
})
}
}
Is it possible to modify the return value definition of this method?