Available on crate feature
prost only.Expand description
Validation and decoding for messages encoded with protobuf using prost
use hedwig::validators::prost::{ProstValidator, ProstDecoder, ExactSchemaMatcher};
#[derive(Clone, PartialEq, ::prost::Message)]
struct MyMessage {
#[prost(string, tag = "1")]
payload: String,
}
let schema = "my-message.proto";
let message = MyMessage {
payload: "foobar".to_owned(),
};
// Demonstrate a message going roundtrip through the validator and the decoder
let validator = ProstValidator::new();
let validated_message = validator.validate(
Uuid::new_v4(),
SystemTime::now(),
schema,
hedwig::Headers::default(),
&message,
)?;
let decoder = ProstDecoder::new(
ExactSchemaMatcher::<MyMessage>::new(schema)
);
let decoded_message = decoder.decode(validated_message)?;
assert_eq!(message, decoded_message);
Structs§
- Exact
Schema Matcher - A
SchemaMatcherwhich expects all incoming schemas to match exactly one string for the given message type - Prost
Decoder - Validator that decodes data from protobuf payloads using
prost. - Prost
Validator - Validator that encodes data into protobuf payloads using
prost. - Prost
Validator Error - Errors that may occur when validating ProtoBuf messages.
- Schema
Mismatch Error - An error indicating that a received message had a schema which did not match the deserialized message type
Enums§
- Prost
Decode Error - Errors that may occur when decoding ProtoBuf messages.
Traits§
- Schema
Matcher - A means of asserting that an incoming message’s
schemamatches a given message type’s deserialized format.