Skip to main content

DocumentValidator

Struct DocumentValidator 

Source
pub struct DocumentValidator<'a> { /* private fields */ }
Expand description

Validates instance documents against a compiled schema.

Holds a ValueValidator, so simple types are prepared once and reused across documents.

Implementations§

Source§

impl<'a> DocumentValidator<'a>

Source

pub fn new(schemas: &'a Schemas) -> Self

Source

pub fn validate(&self, xml: &str) -> ValidationReport

Validates a document, discarding the PSVI.

Source

pub fn validate_with( &self, xml: &str, sink: impl FnMut(PsviEvent), ) -> ValidationReport

Validates a document, handing every PSVI event to sink.

A callback rather than an iterator: the events are produced inside the streaming loop, and an iterator would have to buffer them.

Source

pub fn validate_named( &self, xml: &str, uri: &str, sink: impl FnMut(PsviEvent), ) -> ValidationReport

Names the document for diagnostics, e.g. a file path.

Source

pub fn validate_until( &self, xml: &str, uri: &str, sink: impl FnMut(PsviEvent) -> ControlFlow<()>, ) -> ValidationReport

Self::validate_named, stopping as soon as sink returns ControlFlow::Break.

For a reader that has what it came for, or has gone away, and should not pay for the rest of a large document. No event follows the one the break answered. The report covers what was read and nothing more, so a stopped read says nothing about whether the rest is valid.

Trait Implementations§

Source§

impl<'a> Debug for DocumentValidator<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for DocumentValidator<'a>

§

impl<'a> RefUnwindSafe for DocumentValidator<'a>

§

impl<'a> Send for DocumentValidator<'a>

§

impl<'a> Sync for DocumentValidator<'a>

§

impl<'a> Unpin for DocumentValidator<'a>

§

impl<'a> UnsafeUnpin for DocumentValidator<'a>

§

impl<'a> UnwindSafe for DocumentValidator<'a>

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, 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

Source§

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

impl<T> Ungil for T
where T: Send,