[−][src]Struct tweep::PassageHeader
A passage header, along with associated Position
, tags, and metadata
Parse Errors
LeadingWhitespace
- Whitespace before the::
sigil on a header lineMissingSigil
- No::
sigil at the beginning of the header lineMetadataBeforeTags
- Metadata and tags present but in wrong orderUnclosedTagBlock
- Tag block present but unclosedUnescapedOpenCurly
- Unescaped{
character in passage nameUnescapedCloseCurly
- Unescaped}
character in passage nameUnescapedOpenSquare
- Unescaped[
character in passage nameUnescapedCloseSquare
- Unescaped]
character in passage nameEmptyName
- No passage name present in header line
Parse Warnings
JsonError
- Error encountered when parsing metadataEscapedOpenCurly
-\{
present in passage nameEscapedCloseCurly
-\}
present in passage nameEscapedOpenSquare
-\[
present in passage nameEscapedCloseSquare
-\]
present in passage name
Examples
use tweep::{Parser, PassageHeader}; let input = r#":: A passage [ tag1 tag2 ] { "position": "5,5" }"#; let header = PassageHeader::parse(input);
Fields
name: String
The name of the header. This can be a Twine passage name or a special name
The list of comma separated tags
metadata: Map<String, Value>
A json object containing metadata for the passage
position: Position
The position of the header
Methods
impl PassageHeader
[src]
pub fn has_tag(&self, tag: &str) -> bool
[src]
Returns true
if this header is tagged with str
Examples
use tweep::{Parser, PassageHeader}; let out = PassageHeader::parse(":: A passage [ foo bar ]"); assert!(out.get_output().as_ref().ok().unwrap().has_tag("foo"));
Trait Implementations
impl Debug for PassageHeader
[src]
impl<'a> Parser<'a> for PassageHeader
[src]
type Output = Output<Result<Self, ErrorList>>
The type produced by this parser
type Input = str
The type accepted by this parser
fn parse(input: &'a Self::Input) -> Self::Output
[src]
impl Positional for PassageHeader
[src]
fn get_position(&self) -> &Position
[src]
fn mut_position(&mut self) -> &mut Position
[src]
fn get_column(&self) -> Option<usize>
[src]
fn set_column(&mut self, col: usize)
[src]
fn offset_column(&mut self, offset: usize)
[src]
fn get_row(&self) -> Option<usize>
[src]
fn set_row(&mut self, row: usize)
[src]
fn offset_row(&mut self, offset: usize)
[src]
fn get_file(&self) -> Option<&str>
[src]
fn set_file(&mut self, file: String)
[src]
fn with_offset_row(self, offset: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_offset_column(self, offset: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_column(self, col: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_row(self, row: usize) -> Self where
Self: Sized,
[src]
Self: Sized,
fn with_file(self, file: String) -> Self where
Self: Sized,
[src]
Self: Sized,
Auto Trait Implementations
impl RefUnwindSafe for PassageHeader
impl Send for PassageHeader
impl Sync for PassageHeader
impl Unpin for PassageHeader
impl UnwindSafe for PassageHeader
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, 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>,