Skip to main content

AsyncObjectSource

Trait AsyncObjectSource 

Source
pub trait AsyncObjectSource {
    // Required methods
    fn get(&self, r: ObjRef) -> BoxFuture<'_, Result<Object>>;
    fn stream_data<'a>(
        &'a self,
        s: &'a Stream,
    ) -> BoxFuture<'a, Result<Vec<u8>>>;
    fn resolve<'a>(&'a self, o: &'a Object) -> BoxFuture<'a, Result<Object>>;
}
Expand description

Reads indirect objects and decodes streams, awaiting whatever I/O that takes.

This is the trait the shared algorithms are written against. A caller who already holds the whole file reaches them through Immediate, which implements this trait with futures that are already complete.

Required Methods§

Source

fn get(&self, r: ObjRef) -> BoxFuture<'_, Result<Object>>

Fetches an indirect object by reference.

Source

fn stream_data<'a>(&'a self, s: &'a Stream) -> BoxFuture<'a, Result<Vec<u8>>>

Decodes a stream’s data through its filter chain, resolving indirect filter parameters against this source.

Source

fn resolve<'a>(&'a self, o: &'a Object) -> BoxFuture<'a, Result<Object>>

Chases reference chains, depth-capped at MAX_RESOLVE_DEPTH.

Lenient in the same way as ObjectSource::resolve: a reference to a missing or unreadable object resolves to Object::Null.

There is no default body. The shared chasing loop lives in resolve_with, which needs Self: Sync because it holds &self across an await; a where clause on a provided method would bind overriding implementors too, and Immediate wraps sources that are deliberately not Sync. An implementor that is Sync should delegate to resolve_with.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: AsyncObjectSource + ?Sized> AsyncObjectSource for &T

A shared reference to an asynchronous source is itself one, forwarding every method — the counterpart of the ObjectSource impl above.

This is what makes “# Signing a shared algorithm” rule 1 cheap rather than merely mandatory. An entry point owns its source so that its future can be 'static, and it still needs to hand that source to shared helpers which own theirs for the same reason — crate::document::page_content_with is the one every page-reading algorithm starts with. Without this impl the owner’s only options are to copy the helper’s body or to give the helper a &S signature that no consumer can spawn.

All three methods forward explicitly because AsyncObjectSource::resolve has no default body, and forwarding is what keeps the wrapped implementor’s own reference chasing rather than substituting the shared loop over get.

Source§

fn get(&self, r: ObjRef) -> BoxFuture<'_, Result<Object>>

Source§

fn stream_data<'a>(&'a self, s: &'a Stream) -> BoxFuture<'a, Result<Vec<u8>>>

Source§

fn resolve<'a>(&'a self, o: &'a Object) -> BoxFuture<'a, Result<Object>>

Implementors§