pub trait ObjectEncoder {
// Required methods
fn encode_string<'a>(&self, owner: ObjId, data: &'a [u8]) -> Cow<'a, [u8]>;
fn encode_stream<'a>(&self, owner: ObjId, data: &'a [u8]) -> Cow<'a, [u8]>;
}Expand description
Transforms a serialized string or stream payload on its way into the file — the §7.6 encryption hook, in identity form for Pass 3.0.
Implementations receive the containing indirect object’s
identifier because §7.6.2’s key derivation is per-object: the
encryption key for object N G mixes the document key with N and
G. A serializer that did not thread the id through would be
unable to host a conforming standard security handler at all, which
is the whole reason this parameter exists in Pass 3.0 where it is
unused.
§Examples
use pdfcer_model::object::ObjId;
use pdfcer_model::writer::{IdentityEncoder, ObjectEncoder};
let enc = IdentityEncoder;
let id = ObjId::new(4, 0);
assert_eq!(&*enc.encode_string(id, b"hello"), b"hello");
assert_eq!(&*enc.encode_stream(id, b"data"), b"data");Required Methods§
Sourcefn encode_string<'a>(&self, owner: ObjId, data: &'a [u8]) -> Cow<'a, [u8]>
fn encode_string<'a>(&self, owner: ObjId, data: &'a [u8]) -> Cow<'a, [u8]>
Transform the decoded bytes of a string object (§7.3.4)
belonging to indirect object owner.
Called with the string’s value, before any literal/hex escaping: §7.6.2 encrypts the string’s value, and the escaping is syntax applied to the result.
Sourcefn encode_stream<'a>(&self, owner: ObjId, data: &'a [u8]) -> Cow<'a, [u8]>
fn encode_stream<'a>(&self, owner: ObjId, data: &'a [u8]) -> Cow<'a, [u8]>
Transform the already-filter-encoded bytes of a stream
(§7.3.8) belonging to indirect object owner.
Called with the bytes that would otherwise be written between
stream and endstream. §7.6.2’s ordering is load-bearing:
encryption is applied after the /Filter chain on write (and
therefore before it on read), so /Length must be computed
from this function’s output, never its input.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".