pub struct Preview { /* private fields */ }Expand description
The result of preview: what an edit would do, computed without side
effects.
Serialises as {"text", "diff", "changes", "strictest_apply_class", "errors", "valid"}.
§Serialisation and redaction
The serialised text and diff show secret-reference values exactly as
they appear in the TOML: the diff must be faithful (contract E1.3), and a
diff that hid lines would not be one. The serialised changes are
FieldChanges, redacted when built, and errors never contain a
secret-reference value. Debug shows only the change list, the strictest
class and the errors, never the text or diff, so {:?} is safe to log.
Send the serialised form only to a caller entitled to read the whole
configuration file, such as the administrator previewing an edit.
Implementations§
Source§impl Preview
impl Preview
Sourcepub fn text(&self) -> &str
pub fn text(&self) -> &str
Returns the edited TOML text. Outside the edited values it is
byte-identical to the base, comments and blank lines included, for a
base that uses one line ending throughout. A base with mixed line
endings is written with the ending of its first line break; see
preview.
Sourcepub fn diff(&self) -> &str
pub fn diff(&self) -> &str
Returns a unified diff from the base text to Preview::text, empty
when nothing changed. Unlike the change list, the diff shows
secret-reference values as they appear in the TOML.
Sourcepub fn changes(&self) -> &[FieldChange]
pub fn changes(&self) -> &[FieldChange]
Returns the changed fields in schema order. Requested changes that leave a field’s effective value as it was are omitted.
Sourcepub fn strictest_apply_class(&self) -> Option<ApplyClass>
pub fn strictest_apply_class(&self) -> Option<ApplyClass>
Returns the most disruptive apply class among the changes, or None
when there are none.
Sourcepub fn errors(&self) -> &[ValidationError]
pub fn errors(&self) -> &[ValidationError]
Returns every validation error in the edited document; empty when it is valid.
Sourcepub fn document(&self) -> Option<&ConfigDocument>
pub fn document(&self) -> Option<&ConfigDocument>
Returns the edited document when it is valid.
Sourcepub fn into_document(self) -> Option<ConfigDocument>
pub fn into_document(self) -> Option<ConfigDocument>
Consumes the preview and returns the edited document when it is valid.
Trait Implementations§
Source§impl Debug for Preview
Shows the change list and errors; the text and diff are elided because
they may contain secret references.
impl Debug for Preview
Shows the change list and errors; the text and diff are elided because they may contain secret references.
impl Eq for Preview
impl StructuralPartialEq for Preview
Auto Trait Implementations§
impl Forget for Preview
impl Freeze for Previewwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<FieldChange>: Freeze,
PhantomData<ValidationError>: Freeze,
PhantomData<Value>: Freeze,
PhantomData<String>: Freeze,
impl Move for Preview
impl RefUnwindSafe for Preview
impl Send for Preview
impl Sync for Previewwhere
RawVecInner: Sync,
impl Unpin for Preview
impl UnsafeUnpin for Previewwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<FieldChange>: UnsafeUnpin,
PhantomData<ValidationError>: UnsafeUnpin,
PhantomData<Value>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
impl UnwindSafe for Preview
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,
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.