Struct Block
pub struct Block {
header: String,
fields: Vec<(String, String)>,
}Expand description
One parsed parity block.
Fields§
§header: StringLine 1, verbatim, version included.
fields: Vec<(String, String)>The key: value lines after the header, in printed order.
Implementations§
§impl Block
impl Block
pub fn parse(source: &str, origin: &str) -> Result<Self, Error>
pub fn parse(source: &str, origin: &str) -> Result<Self, Error>
Parses the block out of everything source printed.
The block is the last thing an example prints, so the scan starts at the last header line and everything above it is ignored — an example is free to print a reader-friendly summary first.
§Errors
Error::Arm naming origin when there is no block, when a line is not
key: value with exactly one space after the colon, when a key repeats,
when a required key is absent, or when the best.param.* lines are not
last and ascending. Every one of those is a printer that does not meet
§17.4, and a lenient parser here would turn a broken printer into a green
gate.
pub fn render(&self) -> String
pub fn render(&self) -> String
The block’s canonical text: the header, the fields, one trailing newline.
A round trip through parse is the identity on a valid
block, which is what lets a golden be written from a parsed block and
re-read without normalisation.
fn check_shape(&self, origin: &str) -> Result<(), Error>
fn check_shape(&self, origin: &str) -> Result<(), Error>
Enforces the parts of §17.4 that are properties of the whole block.
Trait Implementations§
impl Eq for Block
impl StructuralPartialEq for Block
Auto Trait Implementations§
impl Freeze for Block
impl RefUnwindSafe for Block
impl Send for Block
impl Sync for Block
impl Unpin for Block
impl UnsafeUnpin for Block
impl UnwindSafe for Block
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T, U> Imply<T> for U
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more