Struct sgf_parse::SgfNodeBuilder [−][src]
A builder for SgfNode
s.
SgfNode
s are immutable and required to be valid from the time of creation. An SgfNodeBuilder
can be used to construct a complicated game tree which can then be converted to an SgfNode
with little overhead. If you're building an SGF file from scratch, this should be your starting
point. If you want to modify an existing SGF, SgfNode::into_builder
will get you an
SgfNodeBuilder
to work with.
Note that SgfNodeBuilder
performs no validation until you call the build
method. The user
is responsible for ensuring that no invalid combination of properties has been set.
Examples
use sgf_parse::{serialize, SgfNodeBuilder, SgfProp}; let mut node = SgfNodeBuilder::new(); node.properties.push(SgfProp::new("B".to_string(), vec!["jj".to_string()])); let mut child = SgfNodeBuilder::new(); child.properties.push(SgfProp::new("W".to_string(), vec!["cd".to_string()])); node.children.push(child); let node = node.build(); let sgf = serialize(&node); assert_eq!(sgf, "(;B[jj];W[cd])");
Fields
properties: Vec<SgfProp>
children: Vec<SgfNodeBuilder>
is_root: bool
Implementations
impl SgfNodeBuilder
[src]
pub fn new() -> Self
[src]
Return a new empty SgfNodeBuilder
.
pub fn build(self) -> Result<SgfNode, SgfParseError>
[src]
Consume the SgfNodeBuilder
and its children and return an SgfNode
.
Errors
If the SgfNode
or any of its children are invalid, then an error is returned.
Trait Implementations
impl Clone for SgfNodeBuilder
[src]
fn clone(&self) -> SgfNodeBuilder
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Debug for SgfNodeBuilder
[src]
impl Default for SgfNodeBuilder
[src]
fn default() -> SgfNodeBuilder
[src]
impl PartialEq<SgfNodeBuilder> for SgfNodeBuilder
[src]
fn eq(&self, other: &SgfNodeBuilder) -> bool
[src]
fn ne(&self, other: &SgfNodeBuilder) -> bool
[src]
impl StructuralPartialEq for SgfNodeBuilder
[src]
Auto Trait Implementations
impl RefUnwindSafe for SgfNodeBuilder
[src]
impl Send for SgfNodeBuilder
[src]
impl Sync for SgfNodeBuilder
[src]
impl Unpin for SgfNodeBuilder
[src]
impl UnwindSafe for SgfNodeBuilder
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,