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§
Provided Methods§
Sourcefn resolve(&self, o: &Object) -> Result<Object>
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.
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.
Implementors§
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.