pub struct RenderSnapshot {
pub schema_version: u32,
pub width: usize,
pub height: usize,
pub plain: String,
pub ansi: String,
pub segments: Vec<SnapshotSegment>,
pub rows: Option<Vec<Vec<SnapshotRun>>>,
pub regions: Option<Vec<SnapshotRegion>>,
}Expand description
A render captured for comparison.
Schema 1 (RenderSnapshot::capture) stores the segments as rendered.
Schema 2 (RenderSnapshot::capture_frame) stores rows of merged runs
instead, drops control segments, and keeps ansi in the merged encoding;
its segments is empty. Schema 3 (RenderSnapshot::capture_regions)
is schema 2 plus the frame’s semantic regions. RenderSnapshot::diff
compares a schema 2 or 3 snapshot with any schema by what shows, and
compares regions when both snapshots have them. Every schema reads back.
Fields§
§schema_version: u32§width: usize§height: usize§plain: String§ansi: String§segments: Vec<SnapshotSegment>§rows: Option<Vec<Vec<SnapshotRun>>>§regions: Option<Vec<SnapshotRegion>>Implementations§
Source§impl RenderSnapshot
impl RenderSnapshot
Sourcepub fn capture_frame(target: &RenderTarget, renderable: &dyn Renderable) -> Self
pub fn capture_frame(target: &RenderTarget, renderable: &dyn Renderable) -> Self
A schema 2 snapshot, built from the render’s Frame.
Sourcepub fn capture_regions(
target: &RenderTarget,
renderable: &dyn Renderable,
) -> Self
pub fn capture_regions( target: &RenderTarget, renderable: &dyn Renderable, ) -> Self
A schema 3 snapshot: schema 2 plus the regions the renderables
reported (see RenderTarget::frame_with_regions) and the links.
Every field comes from one render, so the regions describe exactly
the stored rows.
Sourcepub fn upgrade(&self) -> Self
pub fn upgrade(&self) -> Self
This snapshot as schema 2: rows of merged runs from its segments. A
schema 2 snapshot is returned unchanged. ansi is kept as captured.
pub fn capture(target: &RenderTarget, renderable: &dyn Renderable) -> Self
pub fn to_json(&self) -> Result<String, SnapshotError>
Sourcepub fn diff(&self, other: &Self) -> Option<String>
pub fn diff(&self, other: &Self) -> Option<String>
How other differs, or None when equal, without hiding style-only
changes: a diff -u of the plain text when it differs, else the
style-changed lines and the first differing segment field, else the
first differing metadata path.
When either snapshot is schema 2 or 3, both are compared as schema 2:
size, plain text and rows, not ansi or how the text was segmented;
and regions too when both have them.
Trait Implementations§
Source§impl Clone for RenderSnapshot
impl Clone for RenderSnapshot
Source§impl Debug for RenderSnapshot
impl Debug for RenderSnapshot
Source§impl<'de> Deserialize<'de> for RenderSnapshot
impl<'de> Deserialize<'de> for RenderSnapshot
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for RenderSnapshot
Source§impl PartialEq for RenderSnapshot
impl PartialEq for RenderSnapshot
Source§impl Serialize for RenderSnapshot
impl Serialize for RenderSnapshot
impl StructuralPartialEq for RenderSnapshot
Auto Trait Implementations§
impl Freeze for RenderSnapshot
impl RefUnwindSafe for RenderSnapshot
impl Send for RenderSnapshot
impl Sync for RenderSnapshot
impl Unpin for RenderSnapshot
impl UnsafeUnpin for RenderSnapshot
impl UnwindSafe for RenderSnapshot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.