Trait ResourceLoaderComponent

Source
pub trait ResourceLoaderComponent:
    Debug
    + Send
    + Sync
    + 'static {
    // Required method
    fn load_resource(
        &self,
        source: &Source,
        ctx: &impl Context,
    ) -> SendBoxFuture<MaybeEncData, ResourceLoadingError>;

    // Provided method
    fn load_transfer_encoded_resource(
        &self,
        resource: &Resource,
        ctx: &impl Context,
    ) -> SendBoxFuture<EncData, ResourceLoadingError> { ... }
}
Expand description

Trait needed to be implemented for providing the resource loading parts to aCompositeContext.

Required Methods§

Source

fn load_resource( &self, source: &Source, ctx: &impl Context, ) -> SendBoxFuture<MaybeEncData, ResourceLoadingError>

Calls to Context::load_resource will be forwarded to this method.

It is the same as Context::load_resource except that a reference to the context containing this component is passed in. To prevent infinite recursion the Context.load_resource method must not be called. Additionally the Context.load_transfer_encoded_resource must not be called if it uses Context.load_resource.

Provided Methods§

Source

fn load_transfer_encoded_resource( &self, resource: &Resource, ctx: &impl Context, ) -> SendBoxFuture<EncData, ResourceLoadingError>

Calls to Context::transfer_encode_resource will be forwarded to this method.

It is the same as Context::transfer_encode_resource except that a reference to the context containing this component is passed in to make the offload and load_resource methods of Context available.

To prevent infinite recursion the load_transfer_encoded_resource method of the context must not be called.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<C> ResourceLoaderComponent for C
where C: Context,

Allows using a part of an context as an component.

Source§

impl<ValidateScheme> ResourceLoaderComponent for FsResourceLoader<ValidateScheme>
where ValidateScheme: ConstSwitch,