pub trait Mockablewhere
Self: Sized,{
// Provided methods
fn mock_serialize(&self) -> Option<Vec<u8>> { ... }
fn mock_deserialize(_data: &[u8]) -> Option<Self> { ... }
}Expand description
Mocking support for messages.
This trait should be implemented by any object that can be used in the DAPI.
We use serde_json to serialize/deserialize messages.
Provided Methods§
Sourcefn mock_serialize(&self) -> Option<Vec<u8>>
fn mock_serialize(&self) -> Option<Vec<u8>>
Serialize the message to bytes for mocking purposes.
Returns None if the message is not serializable or mocking is disabled.
§Panics
Panics on any error.
Sourcefn mock_deserialize(_data: &[u8]) -> Option<Self>
fn mock_deserialize(_data: &[u8]) -> Option<Self>
Deserialize the message serialized with [mock_serialize()].
Returns None if the message is not serializable or mocking is disabled.
§Panics
Panics on any error.
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.
Implementations on Foreign Types§
impl<T: Mockable> Mockable for Streaming<T>
Mocking of gRPC streaming responses is not supported.
This will return None on serialization,
effectively disabling mocking of streaming responses.