Trait riscan_pro::element::Extension [] [src]

pub trait Extension {
    fn child(&self, path: &str) -> Result<&Element>;
fn children(&self, path: &str) -> Result<&Vec<Element>>;
fn as_str(&self) -> Result<&str>;
fn noderef(&self) -> Result<&str>; fn parse_text<T>(&self) -> Result<T>
    where
        T: FromStr,
        Error: From<<T as FromStr>::Err>
, { ... } }

An extension to the xmltree element to make it more ergonomic.

Required Methods

Returns a child element by slash-seperated names, or an error if the path does not exist.

Examples

Extension is implemented for xmltree::Element:

extern crate xmltree;
use xmltree::Element;
use riscan_pro::element::Extension;
use std::fs::File;

let file = File::open("data/project.RiSCAN/project.rsp").unwrap();
let element = Element::parse(file).unwrap();
let pop_matrix = element.child("pop/matrix").unwrap();

Returns a vector of children, as selected by name.

Examples

Extension is implemented for xmltree::Element:

extern crate xmltree;
use xmltree::Element;
use riscan_pro::element::Extension;
use std::fs::File;

let file = File::open("data/project.RiSCAN/project.rsp").unwrap();
let element = Element::parse(file).unwrap();
let relector_clibrations = element.children("calibrations/reflcalibs/reflcalib").unwrap();

Returns this element's inner text as a string, or returns an error if there is no text.

Examples

Extension is implemented for xmltree::Element:

extern crate xmltree;
use xmltree::Element;
use riscan_pro::element::Extension;
use std::fs::File;

let file = File::open("data/project.RiSCAN/project.rsp").unwrap();
let element = Element::parse(file).unwrap();
let pop_matrix_str = element.child("pop/matrix").unwrap().as_str().unwrap();

Returns this element's nodref attribute as a string.

The noderef is trimmed to only use the last element.

Examples

Extension is implemented for xmltree::Element:

extern crate xmltree;
use xmltree::Element;
use riscan_pro::element::Extension;
use std::fs::File;

let file = File::open("data/project.RiSCAN/project.rsp").unwrap();
let element = Element::parse(file).unwrap();
let logo = element
    .child("collections/overlays/overlay/overlayitem/source_ref")
    .unwrap()
    .noderef()
    .unwrap();
assert_eq!("Logo", logo);

Provided Methods

Parses this element's inner text, or returns an error if there is no text or if the parse fails.

Examples

Extension is implemented for xmltree::Element:

extern crate xmltree;
use xmltree::Element;
use riscan_pro::element::Extension;
use std::fs::File;

let file = File::open("data/project.RiSCAN/project.rsp").unwrap();
let element = Element::parse(file).unwrap();
let version: f64 = element.child("app_version").unwrap().parse_text().unwrap();

Implementations on Foreign Types

impl Extension for Element
[src]

[src]

[src]

[src]

[src]

[src]

Implementors