pub struct DocumentConstructor { /* private fields */ }Implementations§
Source§impl DocumentConstructor
impl DocumentConstructor
pub fn new() -> Self
pub fn current_node_id(&self) -> NodeId
pub fn current_node(&self) -> &Node
pub fn current_node_mut(&mut self) -> &mut Node
pub fn current_path(&self) -> &[PathSegment]
pub fn document(&self) -> &EureDocument
pub fn document_mut(&mut self) -> &mut EureDocument
pub fn finish(self) -> EureDocument
Source§impl DocumentConstructor
impl DocumentConstructor
Sourcepub fn begin_scope(&mut self) -> Scope
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).
Sourcepub fn end_scope(&mut self, scope: Scope) -> Result<(), ScopeError>
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.
Navigate to a child node by path segment. Creates the node if it doesn’t exist.
Sourcepub fn require_hole(&self) -> Result<(), InsertError>
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.
Sourcepub fn bind_hole(
&mut self,
label: Option<Identifier>,
) -> Result<(), InsertError>
pub fn bind_hole( &mut self, label: Option<Identifier>, ) -> Result<(), InsertError>
Bind a hole (optionally labeled) to the current node.
Sourcepub fn bind_primitive(
&mut self,
value: PrimitiveValue,
) -> Result<(), InsertError>
pub fn bind_primitive( &mut self, value: PrimitiveValue, ) -> Result<(), InsertError>
Bind a primitive value to the current node. Error if already bound.
Sourcepub fn bind_from(
&mut self,
value: impl Into<PrimitiveValue>,
) -> Result<(), InsertError>
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>.
Sourcepub fn bind_empty_map(&mut self) -> Result<(), InsertError>
pub fn bind_empty_map(&mut self) -> Result<(), InsertError>
Bind an empty map to the current node. Error if already bound.
Sourcepub fn bind_empty_array(&mut self) -> Result<(), InsertError>
pub fn bind_empty_array(&mut self) -> Result<(), InsertError>
Bind an empty array to the current node. Error if already bound.
Sourcepub fn bind_empty_tuple(&mut self) -> Result<(), InsertError>
pub fn bind_empty_tuple(&mut self) -> Result<(), InsertError>
Bind an empty tuple to the current node. Error if already bound.
Sourcepub fn begin_eure_block(&mut self)
pub fn begin_eure_block(&mut self)
Enter a new EureSource block. No-op for DocumentConstructor.
Sourcepub fn set_block_value(&mut self) -> Result<(), InsertError>
pub fn set_block_value(&mut self) -> Result<(), InsertError>
Set the value binding for current block. No-op for DocumentConstructor.
Sourcepub fn end_eure_block(&mut self) -> Result<(), InsertError>
pub fn end_eure_block(&mut self) -> Result<(), InsertError>
End current EureSource block. No-op for DocumentConstructor.
Sourcepub fn begin_binding(&mut self)
pub fn begin_binding(&mut self)
Mark the start of a binding statement. No-op for DocumentConstructor.
Sourcepub fn end_binding_value(&mut self) -> Result<(), InsertError>
pub fn end_binding_value(&mut self) -> Result<(), InsertError>
End binding #1: path = value. No-op for DocumentConstructor.
Sourcepub fn end_binding_block(&mut self) -> Result<(), InsertError>
pub fn end_binding_block(&mut self) -> Result<(), InsertError>
End binding #2/#3: path { eure }. No-op for DocumentConstructor.
Sourcepub fn begin_section(&mut self)
pub fn begin_section(&mut self)
Start a section header. No-op for DocumentConstructor.
Sourcepub fn begin_section_items(&mut self)
pub fn begin_section_items(&mut self)
Begin section #4: items follow. No-op for DocumentConstructor.
Sourcepub fn end_section_items(&mut self) -> Result<(), InsertError>
pub fn end_section_items(&mut self) -> Result<(), InsertError>
End section #4: finalize section with items. No-op for DocumentConstructor.
Sourcepub fn end_section_block(&mut self) -> Result<(), InsertError>
pub fn end_section_block(&mut self) -> Result<(), InsertError>
End section #5/#6: block. No-op for DocumentConstructor.
Source§impl DocumentConstructor
impl DocumentConstructor
Sourcepub fn record<F, T>(&mut self, f: F) -> Result<T, WriteError>
pub fn record<F, T>(&mut self, f: F) -> Result<T, WriteError>
Sourcepub fn tuple<F, T>(&mut self, f: F) -> Result<T, WriteError>
pub fn tuple<F, T>(&mut self, f: F) -> Result<T, WriteError>
Sourcepub fn set_extension<T: IntoEure>(
&mut self,
name: &str,
value: T,
) -> Result<(), WriteError>
pub fn set_extension<T: IntoEure>( &mut self, name: &str, value: T, ) -> Result<(), WriteError>
Sourcepub fn set_extension_optional<T: IntoEure>(
&mut self,
name: &str,
value: Option<T>,
) -> Result<(), WriteError>
pub fn set_extension_optional<T: IntoEure>( &mut self, name: &str, value: Option<T>, ) -> Result<(), WriteError>
Sourcepub fn set_variant(&mut self, variant: &str) -> Result<(), WriteError>
pub fn set_variant(&mut self, variant: &str) -> Result<(), WriteError>
Trait Implementations§
Source§impl Default for DocumentConstructor
impl Default for DocumentConstructor
Source§impl InterpreterSink for DocumentConstructor
impl InterpreterSink for DocumentConstructor
Source§type Error = InsertError
type Error = InsertError
Source§fn begin_scope(&mut self) -> Self::Scope
fn begin_scope(&mut self) -> Self::Scope
end_scope.
Scopes must be ended in LIFO order (most recent first).Source§fn end_scope(&mut self, scope: Self::Scope) -> Result<(), Self::Error>
fn end_scope(&mut self, scope: Self::Scope) -> Result<(), Self::Error>
begin_scope was called.Source§fn require_hole(&self) -> Result<(), Self::Error>
fn require_hole(&self) -> Result<(), Self::Error>
Source§fn bind_primitive(&mut self, value: PrimitiveValue) -> Result<(), Self::Error>
fn bind_primitive(&mut self, value: PrimitiveValue) -> Result<(), Self::Error>
Source§fn bind_hole(&mut self, label: Option<Identifier>) -> Result<(), Self::Error>
fn bind_hole(&mut self, label: Option<Identifier>) -> Result<(), Self::Error>
Source§fn bind_empty_map(&mut self) -> Result<(), Self::Error>
fn bind_empty_map(&mut self) -> Result<(), Self::Error>
Source§fn bind_empty_array(&mut self) -> Result<(), Self::Error>
fn bind_empty_array(&mut self) -> Result<(), Self::Error>
Source§fn bind_empty_tuple(&mut self) -> Result<(), Self::Error>
fn bind_empty_tuple(&mut self) -> Result<(), Self::Error>
Source§fn current_node_id(&self) -> NodeId
fn current_node_id(&self) -> NodeId
Source§fn current_path(&self) -> &[PathSegment]
fn current_path(&self) -> &[PathSegment]
Source§fn document(&self) -> &EureDocument
fn document(&self) -> &EureDocument
Source§fn document_mut(&mut self) -> &mut EureDocument
fn document_mut(&mut self) -> &mut EureDocument
Source§fn bind_from(
&mut self,
value: impl Into<PrimitiveValue>,
) -> Result<(), Self::Error>
fn bind_from( &mut self, value: impl Into<PrimitiveValue>, ) -> Result<(), Self::Error>
Into<PrimitiveValue>.
Convenience method for use with the eure! macro.Source§fn begin_eure_block(&mut self)
fn begin_eure_block(&mut self)
{ eure } patterns).
Pushes a new EureSource onto the builder stack.
Default: no-op.Source§fn set_block_value(&mut self) -> Result<(), Self::Error>
fn set_block_value(&mut self) -> Result<(), Self::Error>
{ = value ... } patterns).
Called after bind_* to record the value node.
Returns error if called without a preceding bind operation.
Default: no-op (returns Ok).Source§fn end_eure_block(&mut self) -> Result<(), Self::Error>
fn end_eure_block(&mut self) -> Result<(), Self::Error>
Source§fn begin_binding(&mut self)
fn begin_binding(&mut self)
path ...).
Default: no-op.Source§fn end_binding_value(&mut self) -> Result<(), Self::Error>
fn end_binding_value(&mut self) -> Result<(), Self::Error>
path = value.
Adds BindingSource with BindSource::Value to current EureSource.
Returns error if called without a preceding bind operation.
Default: no-op (returns Ok).Source§fn end_binding_block(&mut self) -> Result<(), Self::Error>
fn end_binding_block(&mut self) -> Result<(), Self::Error>
path { eure }.
Adds BindingSource with BindSource::Block to current EureSource.
The block’s EureSource was built between begin_eure_block/end_eure_block.
Returns error if called without a preceding end_eure_block.
Default: no-op (returns Ok).Source§fn begin_section(&mut self)
fn begin_section(&mut self)
@ path ...).
Default: no-op.Source§fn begin_section_items(&mut self)
fn begin_section_items(&mut self)
@ section (items follow).
Begins collecting items into SectionBody::Items.
Default: no-op.Source§fn end_section_items(&mut self) -> Result<(), Self::Error>
fn end_section_items(&mut self) -> Result<(), Self::Error>
Source§fn end_section_block(&mut self) -> Result<(), Self::Error>
fn end_section_block(&mut self) -> Result<(), Self::Error>
@ section { eure }.
Adds SectionSource with SectionBody::Block to current EureSource.
The block’s EureSource was built between begin_eure_block/end_eure_block.
Returns error if called without a preceding end_eure_block.
Default: no-op (returns Ok).