Skip to main content

TreeContract

Struct TreeContract 

Source
pub struct TreeContract<S> { /* private fields */ }
Expand description

A tree’s events, held to their contract in front of a sink that takes them as one (a render that writes a document from them): one root value, and in each object a key and then its value, each key once. A value walked from a parsed tree keeps it by construction. A parse streamed as it proceeds may not: it hands on a member its grammar reads twice (JSON’s {"a":1,"a":2}, whose value keeps the last) where a tree has one, and the rule-event adapter refuses most shapes it cannot follow but not every one a grammar can produce. A repeated key in one object is refused with DUPLICATE_MEMBER, and events no tree has (a value where a key is due, a key outside an object, a close with nothing open, a second root) with STREAMABILITY_UNKNOWN, each at the path of the object concerned; the event is not passed on, and what to do then is the host’s (aless falls back once to the parsed value when nothing has been written). Each open object keeps the keys it has had, dropped when it closes, so the cost is a lookup per key and the keys of the objects open at once, which a parse holds in its tree already.

Implementations§

Source§

impl<S> TreeContract<S>

Source

pub fn new(inner: S) -> TreeContract<S>

Source

pub fn inner(&self) -> &S

Source

pub fn into_inner(self) -> S

Trait Implementations§

Source§

impl<S> Sink for TreeContract<S>
where S: Sink,

Source§

fn event(&mut self, ev: JsonEvent<'_>) -> Result<Flow, Fail>

One event. An Err aborts the run; the source stops the parse and the error reaches the caller unchanged.

Auto Trait Implementations§

§

impl<S> Freeze for TreeContract<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for TreeContract<S>
where S: RefUnwindSafe,

§

impl<S> Send for TreeContract<S>
where S: Send,

§

impl<S> Sync for TreeContract<S>
where S: Sync,

§

impl<S> Unpin for TreeContract<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for TreeContract<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for TreeContract<S>
where S: UnwindSafe,

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.