pub struct ExactSchemaMatcher<T> { /* private fields */ }Available on crate feature
prost only.Expand description
A SchemaMatcher which expects all incoming schemas to match exactly one string for the
given message type
use hedwig::validators::prost::{ExactSchemaMatcher, SchemaMatcher, SchemaMismatchError};
struct MyMessage {
// ...
}
let schema = "messages/my-message/my-schema-v1.proto";
let my_matcher = ExactSchemaMatcher::<MyMessage>::new(schema);
assert_eq!(Ok(()), my_matcher.try_match_schema(schema));
let bad_schema = "messages/my-message/my-schema-v2.proto";
assert_eq!(
Err(SchemaMismatchError::new::<MyMessage>(
schema,
bad_schema.to_owned()
)),
my_matcher.try_match_schema(bad_schema)
);Implementations§
Trait Implementations§
Source§impl<T> SchemaMatcher<T> for ExactSchemaMatcher<T>
impl<T> SchemaMatcher<T> for ExactSchemaMatcher<T>
Source§type InvalidSchemaError = SchemaMismatchError
type InvalidSchemaError = SchemaMismatchError
The error returned when a given schema does not match the message type
Source§fn try_match_schema(&self, schema: &str) -> Result<(), Self::InvalidSchemaError>
fn try_match_schema(&self, schema: &str) -> Result<(), Self::InvalidSchemaError>
Check whether messages with the given schema are valid for deserializing into the trait’s
generic message type. Read more
Auto Trait Implementations§
impl<T> Freeze for ExactSchemaMatcher<T>
impl<T> RefUnwindSafe for ExactSchemaMatcher<T>
impl<T> Send for ExactSchemaMatcher<T>
impl<T> Sync for ExactSchemaMatcher<T>
impl<T> Unpin for ExactSchemaMatcher<T>
impl<T> UnsafeUnpin for ExactSchemaMatcher<T>
impl<T> UnwindSafe for ExactSchemaMatcher<T>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request