pub(super) struct MonolingualClient {
http: Client,
}Expand description
Monolingual dictionary HTTP client.
Handles all network operations: fetching the remote metadata catalogue and downloading dictionary archives. All persistence is handled by the service layer; this type carries no database state.
Fields§
§http: ClientImplementations§
Source§impl MonolingualClient
impl MonolingualClient
Sourcepub(super) fn new() -> Result<Self, MonolingualError>
pub(super) fn new() -> Result<Self, MonolingualError>
Creates a new monolingual HTTP client.
§Errors
Returns an error if the underlying HTTP client fails to build.
Sourcepub(super) fn fetch_metadata(
&self,
) -> Result<HashMap<String, HashMap<String, DictionaryEntry>>, MonolingualError>
pub(super) fn fetch_metadata( &self, ) -> Result<HashMap<String, HashMap<String, DictionaryEntry>>, MonolingualError>
Fetches dictionary metadata from the remote API and returns the parsed response.
The caller is responsible for persisting the result to the database.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub(super) fn is_metadata_modified_since(
&self,
since: UnixTimestamp,
) -> Result<bool, MonolingualError>
pub(super) fn is_metadata_modified_since( &self, since: UnixTimestamp, ) -> Result<bool, MonolingualError>
Sends a HEAD request with If-Modified-Since: <since> and returns
false if the server responds 304 (cache still valid) or true if
the server responds 200 (new data available).
§Errors
Returns an error if the HTTP request fails or returns an unexpected status code.
Sourcepub(super) fn download<F>(
&self,
url: &str,
dest: &Path,
progress_callback: &mut F,
) -> Result<(), MonolingualError>
pub(super) fn download<F>( &self, url: &str, dest: &Path, progress_callback: &mut F, ) -> Result<(), MonolingualError>
Downloads url to dest using chunked HTTP Range requests.
Issues a minimal bytes=0-0 Range request first to read Content-Range
and obtain the total file size, then delegates to the chunked
crate::http::Client::download method which handles retries and
adaptive chunk sizing.
progress_callback receives (bytes_downloaded_so_far, total_bytes)
after each chunk.
§Errors
Returns an error if the probe request fails or returns a non-2xx
status, if the Content-Range header is missing, or if the chunked
download fails.
Trait Implementations§
Source§impl Clone for MonolingualClient
impl Clone for MonolingualClient
Source§fn clone(&self) -> MonolingualClient
fn clone(&self) -> MonolingualClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for MonolingualClient
impl !RefUnwindSafe for MonolingualClient
impl Send for MonolingualClient
impl Sync for MonolingualClient
impl Unpin for MonolingualClient
impl UnsafeUnpin for MonolingualClient
impl !UnwindSafe for MonolingualClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§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>
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>
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