DocumentConstructor

Struct DocumentConstructor 

Source
pub struct DocumentConstructor { /* private fields */ }

Implementations§

Source§

impl DocumentConstructor

Source

pub fn new() -> Self

Source

pub fn current_node_id(&self) -> NodeId

Source

pub fn current_node(&self) -> &Node

Source

pub fn current_node_mut(&mut self) -> &mut Node

Source

pub fn current_path(&self) -> &[PathSegment]

Source

pub fn document(&self) -> &EureDocument

Source

pub fn document_mut(&mut self) -> &mut EureDocument

Source

pub fn finish(self) -> EureDocument

Source§

impl DocumentConstructor

Source

pub fn begin_scope(&mut self) -> Scope

Begin a new scope. Returns a scope handle that must be passed to end_scope. Scopes must be ended in LIFO order (most recent first).

Source

pub fn end_scope(&mut self, scope: Scope) -> Result<(), ScopeError>

End a scope, restoring the constructor to the state when the scope was created. Returns an error if the scope is not the most recent outstanding scope.

Source

pub fn navigate(&mut self, segment: PathSegment) -> Result<NodeId, InsertError>

Navigate to a child node by path segment. Creates the node if it doesn’t exist.

Source

pub fn require_hole(&self) -> Result<(), InsertError>

Validate that the current node is a Hole (unbound). Use this before binding a value to ensure the node hasn’t already been assigned.

Source

pub fn bind_hole(&mut self) -> Result<(), InsertError>

Source

pub fn bind_primitive( &mut self, value: PrimitiveValue, ) -> Result<(), InsertError>

Bind a primitive value to the current node. Error if already bound.

Source

pub fn bind_from( &mut self, value: impl Into<PrimitiveValue>, ) -> Result<(), InsertError>

Bind a value to the current node using Into<PrimitiveValue>.

This is a convenience method for use with the eure! macro. It accepts any type that implements Into<PrimitiveValue>.

Source

pub fn bind_empty_map(&mut self) -> Result<(), InsertError>

Bind an empty map to the current node. Error if already bound.

Source

pub fn bind_empty_array(&mut self) -> Result<(), InsertError>

Bind an empty array to the current node. Error if already bound.

Source

pub fn bind_empty_tuple(&mut self) -> Result<(), InsertError>

Bind an empty tuple to the current node. Error if already bound.

Trait Implementations§

Source§

impl Default for DocumentConstructor

Source§

fn default() -> Self

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

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> 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 = 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.