RequestTrait

Trait RequestTrait 

Source
pub trait RequestTrait {
    // Required methods
    fn headers(&self) -> HashMap<String, String>;
    fn insert_headers(&mut self, headers: HashMap<String, String>);

    // Provided methods
    fn request_type(&self) -> &'static str { ... }
    fn body(&self) -> Vec<u8> 
       where Self: Serialize { ... }
    fn request_id(&self) -> String { ... }
    fn to_payload(&self, client_ip: &str) -> Payload
       where Self: Serialize { ... }
    fn from_payload<T>(value: &Payload) -> T
       where T: for<'a> Deserialize<'a> + Default { ... }
}
Expand description

Base trait for all request types

Required Methods§

Source

fn headers(&self) -> HashMap<String, String>

Get request headers

Source

fn insert_headers(&mut self, headers: HashMap<String, String>)

Insert headers into the request

Provided Methods§

Source

fn request_type(&self) -> &'static str

Get request type identifier

Source

fn body(&self) -> Vec<u8>
where Self: Serialize,

Serialize request body to bytes

Source

fn request_id(&self) -> String

Get unique request identifier

Source

fn to_payload(&self, client_ip: &str) -> Payload
where Self: Serialize,

Convert to gRPC Payload

Source

fn from_payload<T>(value: &Payload) -> T
where T: for<'a> Deserialize<'a> + Default,

Deserialize request from gRPC payload

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.

Implementors§