Skip to main content

ObjectSource

Trait ObjectSource 

Source
pub trait ObjectSource {
    // Required methods
    fn get(&self, r: ObjRef) -> Result<Object>;
    fn stream_data(&self, s: &Stream) -> Result<Vec<u8>>;

    // Provided method
    fn resolve(&self, o: &Object) -> Result<Object> { ... }
}
Expand description

Reads indirect objects and decodes streams, with the whole file already available.

Implement get and stream_data; resolve has a provided implementation that chases reference chains through get via resolve_sync_with. An implementor should override resolve only if its chasing genuinely differs; one that just wants the shared chase — as Document does — needs nothing.

Required Methods§

Source

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

Fetches an indirect object by reference.

Source

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

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

Provided Methods§

Source

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

Chases reference chains, depth-capped at MAX_RESOLVE_DEPTH.

Lenient: a reference to a missing or unreadable object resolves to Object::Null. Exceeding the depth cap is crate::error::Error::CircularReference.

The loop itself lives in resolve_sync_with, which this delegates to; an implementor overriding this method should delegate there too unless its chasing genuinely differs.

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: ObjectSource + ?Sized> ObjectSource for &T

A shared reference to a source is itself a source, forwarding every method.

This is what lets a synchronous entry point that only holds &self wrap itself for the asynchronous implementation — Immediate(self) builds an Immediate<&Self> — without cloning or owning the document. Forwarding resolve explicitly keeps the wrapped implementor’s own reference chasing rather than falling back to the provided loop over get.

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl ObjectSource for Document

Forwards to the inherent methods, so reading a document through the trait is bit-identical to reading it directly. resolve is forwarded too, even though the provided implementation is now the same shared chase (crate::source::resolve_sync_with) that the inherent method delegates to: routing it through the inherent method keeps the two entry points a single call, so they cannot drift should Document::resolve ever grow document-specific behaviour.