Struct HostImageLoader
pub struct HostImageLoader { /* private fields */ }Expand description
The loading half of a host-driven ImageStore.
The host drains requested URLs with take_requests,
fetches them however it can (asynchronously, from its own cache, over its
own transport) and hands the bytes back through
complete, which decodes them under the same size and
cache limits as the native loader and wakes the component that owns the
store. Dropping the loader settles every unfinished request as failed.
Implementations§
§impl HostImageLoader
impl HostImageLoader
pub fn reserve(&mut self, url: &str) -> Option<ImageCompletionTicket>
pub fn reserve(&mut self, url: &str) -> Option<ImageCompletionTicket>
Reserve a request already handed out by this loader for off-thread decode. Unknown, settled, closed-owner or already reserved requests are rejected.
pub fn complete_decoded(
&mut self,
ticket: &ImageCompletionTicket,
decoded: Option<DecodedImage>,
) -> bool
pub fn complete_decoded( &mut self, ticket: &ImageCompletionTicket, decoded: Option<DecodedImage>, ) -> bool
Settle an exact reservation with decoded pixels, or None on failure.
Validation enforces this ticket’s output bound and exact RGBA length.
Foreign, canceled, duplicate and old-generation replies are inert.
A borrowed ticket leaves foreign-loader attempts unable to cancel its owner.
pub fn cancel(&mut self, ticket: &ImageCompletionTicket) -> bool
pub fn cancel(&mut self, ticket: &ImageCompletionTicket) -> bool
Cancel one exact reservation. A late result or later ticket drop is inert.
Closed-owner cleanup releases custody but returns false without publication.
pub fn take_requests(&mut self) -> Vec<String>
pub fn take_requests(&mut self) -> Vec<String>
Every URL requested since the last call. Each must eventually be
passed to complete.
pub fn next_request(&mut self) -> Option<String>
pub fn next_request(&mut self) -> Option<String>
The next requested URL, if any.
pub fn complete(&mut self, url: &str, bytes: Option<&[u8]>) -> bool
pub fn complete(&mut self, url: &str, bytes: Option<&[u8]>) -> bool
Settle a request taken from this loader with fetched bytes, or None
on failure. Decoding runs on the calling thread. Reserved asynchronous
requests must instead use complete_decoded.
Trait Implementations§
§impl Drop for HostImageLoader
impl Drop for HostImageLoader
Auto Trait Implementations§
impl Freeze for HostImageLoader
impl RefUnwindSafe for HostImageLoader
impl Send for HostImageLoader
impl !Sync for HostImageLoader
impl Unpin for HostImageLoader
impl UnsafeUnpin for HostImageLoader
impl UnwindSafe for HostImageLoader
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
§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>. Box<dyn Any> can
then be further downcast into Box<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>. Rc<Any> 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> 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