[−][src]Enum marked_yaml::types::Node
A marked YAML node
NOTE: Nodes are considered equal even if they don't come from the same place. i.e. their spans are ignored for equality and hashing
use marked_yaml::parse_yaml; let node = parse_yaml(100, "{foo: bar}").unwrap(); assert!(node.as_mapping().is_some());
Variants
Scalar(MarkedScalarNode)A YAML scalar
You can test if a node is a scalar, and retrieve it as one if you so wish.
Mapping(MarkedMappingNode)A YAML mapping
You can test if a node is a mapping, and retrieve it as one if you so wish.
Sequence(MarkedSequenceNode)A YAML sequence
You can test if a node is a sequence, and retrieve it as one if you so wish.
Methods
impl Node[src]
pub fn span(&self) -> &Span[src]
Retrieve the Span from the contained Node
let node: Node = "foobar".into(); let span = node.span(); assert_eq!(span.start(), None);
pub fn span_mut(&mut self) -> &mut Span[src]
Retrieve the Span from the contained Node, mutably
let mut node: Node = "foobar".into(); let mut span = node.span_mut(); assert_eq!(span.start(), None); span.set_start(Some(Marker::new(0, 1, 0))); assert_eq!(span.start(), Some(&Marker::new(0, 1, 0)));
pub fn as_scalar(&self) -> Option<&MarkedScalarNode>[src]
Retrieve the scalar from this node if there is one
let node: Node = "foobar".into(); let scalar = node.as_scalar(); assert!(scalar.is_some());
pub fn as_sequence(&self) -> Option<&MarkedSequenceNode>[src]
Retrieve the sequence from this node if there is one
let node: Node = vec!["foobar"].into(); let sequence = node.as_sequence(); assert!(sequence.is_some());
pub fn as_mapping(&self) -> Option<&MarkedMappingNode>[src]
Retrieve the mapping from this node if there is one
let node: Node = parse_yaml(0, "{foobar: baz}").unwrap(); let mapping = node.as_mapping(); assert!(mapping.is_some());
pub fn as_scalar_mut(&mut self) -> Option<&mut MarkedScalarNode>[src]
Retrieve the scalar from this node if there is one, mutably
let mut node: Node = "foobar".into(); let mut scalar = node.as_scalar_mut(); assert!(scalar.is_some());
pub fn as_sequence_mut(&mut self) -> Option<&mut MarkedSequenceNode>[src]
Retrieve the sequence from this node if there is one, mutably
let mut node: Node = vec!["foobar"].into(); let mut sequence = node.as_sequence_mut(); assert!(sequence.is_some());
pub fn as_mapping_mut(&mut self) -> Option<&mut MarkedMappingNode>[src]
Retrieve the mapping from this node if there is one, mutably
let mut node: Node = parse_yaml(0, "{foobar: baz}").unwrap(); let mut mapping = node.as_mapping_mut(); assert!(mapping.is_some());
Trait Implementations
impl Clone for Node[src]
impl Debug for Node[src]
impl Eq for Node[src]
impl From<LinkedHashMap<MarkedScalarNode, Node, RandomState>> for Node[src]
fn from(value: LinkedHashMap<MarkedScalarNode, Node>) -> Node[src]
impl From<MarkedMappingNode> for Node[src]
fn from(value: MarkedMappingNode) -> Node[src]
impl From<MarkedSequenceNode> for Node[src]
fn from(value: MarkedSequenceNode) -> Node[src]
impl From<Node> for YamlNode[src]
impl<T> From<T> for Node where
T: Into<MarkedScalarNode>, [src]
T: Into<MarkedScalarNode>,
impl<T> From<Vec<T>> for Node where
T: Into<Node>, [src]
T: Into<Node>,
impl Hash for Node[src]
fn hash<__H: Hasher>(&self, state: &mut __H)[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher, 1.3.0[src]
H: Hasher,
impl PartialEq<Node> for Node[src]
impl StructuralEq for Node[src]
impl StructuralPartialEq for Node[src]
impl TryFrom<Yaml> for Node[src]
type Error = YamlConversionError
The type returned in the event of a conversion error.
fn try_from(value: YamlNode) -> Result<Self, Self::Error>[src]
Convert from any yaml_rust::Yaml to a Node
let docs = YamlLoader::load_from_str("[1, 2]").unwrap(); let yaml = docs.into_iter().next().unwrap(); let node = Node::try_from(yaml).unwrap();
Auto Trait Implementations
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnwindSafe for Node
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,
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.
fn to_owned(&self) -> T[src]
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.
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>,