pub struct PlantUmlFileData { /* private fields */ }
Expand description

PlantUML diagrams in the file.

Examples

use plantuml_parser::PlantUmlFileData;

let data = r#"
@startuml diagram_0
Alice -> Bob: Hello
@enduml

@startuml
Bob -> Alice: Hi
@enduml

@startuml diagram_2
Alice -> Bob: How are you?
@enduml
"#;

let filedata = PlantUmlFileData::parse_from_str(data)?;
assert_eq!(filedata.is_empty(), false);
assert_eq!(filedata.len(), 3);
assert_eq!(
    filedata.iter().map(|x| x.inner()).collect::<Vec<_>>(),
    [
        "Alice -> Bob: Hello\n",
        "Bob -> Alice: Hi\n",
        "Alice -> Bob: How are you?\n",
    ]
);

let content_1 = filedata.get(1).unwrap();
assert_eq!(content_1.inner(), "Bob -> Alice: Hi\n");
let content_0 = filedata.get_by_id("diagram_0").unwrap();
assert_eq!(content_0.inner(), "Alice -> Bob: Hello\n");
let content_2 = filedata.get_by_id("diagram_2").unwrap();
assert_eq!(content_2.inner(), "Alice -> Bob: How are you?\n");

Implementations§

source§

impl PlantUmlFileData

source

pub fn parse_from_str<S>(input: S) -> Result<Self, Error>
where S: Into<String>,

Creates a new PlantUmlFileData from the string.

  • input - a string to be parsed.
source

pub fn parse(input: ParseContainer) -> Result<Self, Error>

Creates a new PlantUmlFileData from the inner type (ParseContainer).

  • input - a string to be parsed.
source

pub fn get_by_token(&self, token: &IncludeToken) -> Option<&PlantUmlContent>

Returns the one PlantUML diagram specified by the token.

source

pub fn get(&self, index: usize) -> Option<&PlantUmlContent>

Returns the reference to PlantUmlContent of index.

source

pub fn get_by_id(&self, id: &str) -> Option<&PlantUmlContent>

Returns the reference to PlantUmlContent of id.

source

pub fn iter(&self) -> Iter<'_, PlantUmlContent>

Returns an iterator visiting all PlantUmlContent in the PlantUmlFileData.

source

pub fn is_empty(&self) -> bool

Returns true if the PlantUmlFileData has no PlantUmlContent.

source

pub fn len(&self) -> usize

Returns the number of PlantUmlContent in the PlantUmlFileData.

Trait Implementations§

source§

impl Clone for PlantUmlFileData

source§

fn clone(&self) -> PlantUmlFileData

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for PlantUmlFileData

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more