Struct Node

Source
pub struct Node {
    pub tag: String,
    pub attributes: HashMap<String, String>,
    pub content: String,
    /* private fields */
}

Fields§

§tag: String§attributes: HashMap<String, String>§content: String

Implementations§

Source§

impl Node

Source

pub fn get_nodes(&self, tag: &str) -> Option<&Vec<Node>>

Returns a list of all nodes with the specified tag If no nodes with the specified tag exists, None is returned

Source

pub fn try_get_nodes(&self, tag: &str) -> Result<&Vec<Node>, Error>

Returns a list of all nodes with the specified tag If no nodes with the specified tag exists, an Err of TagNotFound is returned containing the parent name and requested node name Otherwise, works exactly like get_nodes but can be chained with ? (try operator)

Source

pub fn add_attribute(&mut self, key: &str, val: &str) -> Option<String>

Adds or updates an attribute If an attribute with that key already exists it is returned

Source

pub fn get_attribute(&self, key: &str) -> Option<&String>

Source

pub fn try_get_attribute(&self, key: &str) -> Result<&String, Error>

Gets an attribute by name or returns an Err of AttributeNotFound containing the parent tag and the requested key Otherwise, works exactly like get_nodes but can be chained with ? (try operator)

Source

pub fn add_node(&mut self, node: Node)

Inserts a new node node with the name of the node field

Source

pub fn add_new_node(&mut self, tag: &str, content: String)

Inserts a new node into the xml structure Does the same thing as node.add_node(simple_xml::new(tag, content));

Source

pub fn save_to_file<P: AsRef<Path>>(&self, path: P) -> Result<()>

This writes an xml structure to a file specified by path Uses the non-pretty to_string formatting

Source

pub fn save_to_file_pretty<P: AsRef<Path>>(&self, path: P) -> Result<()>

This writes an xml structure to a file specified by path Uses the pretty to_string_pretty formatting

Source

pub fn to_string_pretty(&self) -> String

Trait Implementations§

Source§

impl Debug for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Node

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Index<&str> for Node

Returns a slice of all node nodes with the specified tag If no nodes with the specified tag exists, an empty slice is returned

Source§

type Output = [Node]

The returned type after indexing.
Source§

fn index(&self, tag: &str) -> &Self::Output

Performs the indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl Freeze for Node

§

impl RefUnwindSafe for Node

§

impl Send for Node

§

impl Sync for Node

§

impl Unpin for Node

§

impl UnwindSafe for Node

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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.