Skip to main content

PageGraphSignature

Struct PageGraphSignature 

Source
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

Source

pub fn of_graph(graph: &PageGraph) -> Self

Sign every page of graph, in page order.

Source

pub fn pages(&self) -> &[PageBoundarySignature]

The per-page signatures, in page order.

Source

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

Source§

fn clone(&self) -> PageGraphSignature

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PageGraphSignature

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PageGraphSignature

Source§

fn default() -> PageGraphSignature

Returns the “default value” for a type. Read more
Source§

impl Hash for PageGraphSignature

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for PageGraphSignature

Source§

fn eq(&self, other: &PageGraphSignature) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for PageGraphSignature

Source§

impl StructuralPartialEq for PageGraphSignature

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

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
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.