pub struct PageGraphSignature(Vec<PageBoundarySignature>);Expand description
The ordered per-page boundary signatures of a whole PageGraph.
Comparing two graph signatures answers both “did pagination change?”
(inequality) and “where?” (first_divergence).
§Examples
use mos_layout::{LayoutEngine, PageGraphSignature};
use mos_core::Document;
use std::path::PathBuf;
let doc = Document::new(PathBuf::from("doc.mos"));
let result = LayoutEngine::new().layout(&doc);
let signature = PageGraphSignature::of_graph(&result.graph);
// An unchanged layout signs identically and diverges nowhere.
assert_eq!(signature, PageGraphSignature::of_graph(&result.graph));
assert_eq!(signature.first_divergence(&signature), None);Tuple Fields§
§0: Vec<PageBoundarySignature>Implementations§
Source§impl PageGraphSignature
impl PageGraphSignature
Sourcepub fn pages(&self) -> &[PageBoundarySignature]
pub fn pages(&self) -> &[PageBoundarySignature]
The per-page signatures, in page order.
Sourcepub fn first_divergence(&self, other: &Self) -> Option<usize>
pub fn first_divergence(&self, other: &Self) -> Option<usize>
The index of the first page whose signature differs from other, or
None if the two are identical.
When one graph is a prefix of the other (a page was added or removed at the end), the divergence is the length of the shorter graph; the first page index that exists in one but not the other.
§Examples
use mos_layout::PageGraphSignature;
let empty = PageGraphSignature::default();
assert_eq!(empty.first_divergence(&empty), None);Trait Implementations§
Source§impl Clone for PageGraphSignature
impl Clone for PageGraphSignature
Source§fn clone(&self) -> PageGraphSignature
fn clone(&self) -> PageGraphSignature
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PageGraphSignature
impl Debug for PageGraphSignature
Source§impl Default for PageGraphSignature
impl Default for PageGraphSignature
Source§fn default() -> PageGraphSignature
fn default() -> PageGraphSignature
Returns the “default value” for a type. Read more
Source§impl Hash for PageGraphSignature
impl Hash for PageGraphSignature
Source§impl PartialEq for PageGraphSignature
impl PartialEq for PageGraphSignature
impl Eq for PageGraphSignature
impl StructuralPartialEq for PageGraphSignature
Auto Trait Implementations§
impl Freeze for PageGraphSignature
impl RefUnwindSafe for PageGraphSignature
impl Send for PageGraphSignature
impl Sync for PageGraphSignature
impl Unpin for PageGraphSignature
impl UnsafeUnpin for PageGraphSignature
impl UnwindSafe for PageGraphSignature
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
Convert this type into
T, using the provided data to resolve any offsets.