pub struct Input { /* private fields */ }Expand description
A named YAML text, ready to parse and validate.
Implementations§
Source§impl Input
impl Input
Sourcepub fn new(name: impl Into<String>, text: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, text: impl Into<String>) -> Self
An input from text already in memory.
Sourcepub fn read(path: &Path) -> Result<Self, InputError>
pub fn read(path: &Path) -> Result<Self, InputError>
Sourcepub fn frontmatter(&self) -> Option<(Self, &str)>
pub fn frontmatter(&self) -> Option<(Self, &str)>
Split YAML frontmatter from a Markdown body: the text between a first
line of --- and the next line of ---. Problems in the frontmatter
keep the line numbers of the whole file. None when the text does not
start with a --- line, or never closes it.
Sourcepub fn limits(self, limits: Limits) -> Self
pub fn limits(self, limits: Limits) -> Self
Override limits for this input alone, above every other tier: see
Limits for the order.
Sourcepub fn parse<T: DeserializeOwned>(&self) -> Result<T, InputError>
pub fn parse<T: DeserializeOwned>(&self) -> Result<T, InputError>
Parse the text’s shape. Only true and false are booleans, and a
duplicate key or a merge key (<<) is refused. The text must fit the
limits in force, field by field from this input, the repository’s
REPO_FILE, the process default, and serde-saphyr’s own defaults.
§Errors
An InputError with the parser’s problem and its line. A limit
problem names the limit, its value, and where to raise it.
Sourcepub fn check<T: Validate + ?Sized>(
&self,
value: &T,
context: &T::Context,
) -> Result<(), InputError>
pub fn check<T: Validate + ?Sized>( &self, value: &T, context: &T::Context, ) -> Result<(), InputError>
Validate a parsed value against context, and place each of garde’s
problems on the line of the field it names, or of its nearest written
ancestor.
§Errors
An InputError with every problem garde reports.
Sourcepub fn load<T>(&self) -> Result<T, InputError>
pub fn load<T>(&self) -> Result<T, InputError>
Trait Implementations§
impl Eq for Input
impl StructuralPartialEq for Input
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnsafeUnpin for Input
impl UnwindSafe for Input
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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