use std::sync::Arc;
use bytes::Bytes;
use super::{CallId, ClientId, Service};
#[derive(Clone)]
pub struct Request {
service: Arc<Service>,
client_id: ClientId,
call_id: CallId,
encoding: String,
payload: Bytes,
}
impl std::fmt::Debug for Request {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Request")
.field("service", &self.service)
.field("client_id", &self.client_id)
.field("call_id", &self.call_id)
.field("encoding", &self.encoding)
.finish_non_exhaustive()
}
}
impl Request {
pub(crate) fn new(
service: Arc<Service>,
client_id: ClientId,
call_id: CallId,
encoding: String,
payload: Bytes,
) -> Self {
Self {
service,
client_id,
call_id,
encoding,
payload,
}
}
pub fn service_name(&self) -> &str {
self.service.name()
}
pub fn client_id(&self) -> ClientId {
self.client_id
}
pub fn call_id(&self) -> CallId {
self.call_id
}
pub fn encoding(&self) -> &str {
&self.encoding
}
pub fn payload(&self) -> &[u8] {
&self.payload
}
pub fn into_payload(self) -> Bytes {
self.payload
}
}