pub trait UnitHttpMessage {
// Required methods
fn header(&self, header: &str) -> Option<&str>;
fn headers(&self) -> &Vec<(String, String)>;
fn body(&self) -> &[u8] ⓘ;
fn property<K: Into<String>>(&self, key: Vec<K>) -> Option<Bytes>;
fn properties(&self) -> HashMap<Vec<String>, Bytes>;
fn authentication(&self) -> Option<AuthenticationData>;
fn violation(&self) -> Option<PolicyViolation>;
}Expand description
Common read-only accessors for HTTP messages in unit tests.
Implemented by both UnitHttpRequest and UnitHttpResponse, allowing test helper
functions to be written generically over either type.
§Example
ⓘ
use pdk_unit::{UnitHttpMessage, UnitHttpRequest, UnitHttpResponse};
fn assert_ok<M: UnitHttpMessage>(msg: &M) {
assert!(msg.body().len() > 0);
}Required Methods§
Sourcefn header(&self, header: &str) -> Option<&str>
fn header(&self, header: &str) -> Option<&str>
Returns the value of the header with the given name, or None if not present.
Sourcefn headers(&self) -> &Vec<(String, String)>
fn headers(&self) -> &Vec<(String, String)>
Returns all headers as a list of (name, value) pairs.
Sourcefn property<K: Into<String>>(&self, key: Vec<K>) -> Option<Bytes>
fn property<K: Into<String>>(&self, key: Vec<K>) -> Option<Bytes>
Returns the value of a property identified by the given key path, or None if not set.
Sourcefn properties(&self) -> HashMap<Vec<String>, Bytes>
fn properties(&self) -> HashMap<Vec<String>, Bytes>
Returns all properties as a map of key path to raw bytes.
Sourcefn authentication(&self) -> Option<AuthenticationData>
fn authentication(&self) -> Option<AuthenticationData>
Returns the authentication data attached to this message, if any.
Sourcefn violation(&self) -> Option<PolicyViolation>
fn violation(&self) -> Option<PolicyViolation>
Returns the policy violation attached to this message, if any.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.