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
impl PlantUmlFileData
Sourcepub fn parse_from_str<S>(input: S) -> Result<Self, Error>
pub fn parse_from_str<S>(input: S) -> Result<Self, Error>
Creates a new PlantUmlFileData
from the string.
input
- a string to be parsed.
Sourcepub fn parse(input: ParseContainer) -> Result<Self, Error>
pub fn parse(input: ParseContainer) -> Result<Self, Error>
Creates a new PlantUmlFileData
from the inner type (ParseContainer
).
input
- a string to be parsed.
Sourcepub fn get_by_token(&self, token: &IncludeToken) -> Option<&PlantUmlContent>
pub fn get_by_token(&self, token: &IncludeToken) -> Option<&PlantUmlContent>
Returns the one PlantUML diagram specified by the token.
token
- AIncludeToken
to getPlantUmlContent
in thePlantUmlFileData
.
Sourcepub fn get(&self, index: usize) -> Option<&PlantUmlContent>
pub fn get(&self, index: usize) -> Option<&PlantUmlContent>
Returns the reference to PlantUmlContent
of index.
Sourcepub fn get_by_id(&self, id: &str) -> Option<&PlantUmlContent>
pub fn get_by_id(&self, id: &str) -> Option<&PlantUmlContent>
Returns the reference to PlantUmlContent
of id
.
Sourcepub fn iter(&self) -> Iter<'_, PlantUmlContent>
pub fn iter(&self) -> Iter<'_, PlantUmlContent>
Returns an iterator visiting all PlantUmlContent
in the PlantUmlFileData
.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if the PlantUmlFileData
has no PlantUmlContent
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of PlantUmlContent
in the PlantUmlFileData
.
Trait Implementations§
Source§impl Clone for PlantUmlFileData
impl Clone for PlantUmlFileData
Source§fn clone(&self) -> PlantUmlFileData
fn clone(&self) -> PlantUmlFileData
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl Freeze for PlantUmlFileData
impl RefUnwindSafe for PlantUmlFileData
impl Send for PlantUmlFileData
impl Sync for PlantUmlFileData
impl Unpin for PlantUmlFileData
impl UnwindSafe for PlantUmlFileData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more