saluki_core/data_model/payload/grpc/
mod.rs

1use saluki_common::buf::FrozenChunkedBytesBuffer;
2use stringtheory::MetaString;
3
4use super::PayloadMetadata;
5
6/// A gRPC payload.
7#[derive(Clone)]
8pub struct GrpcPayload {
9    metadata: PayloadMetadata,
10    endpoint: MetaString,
11    service_path: MetaString,
12    body: FrozenChunkedBytesBuffer,
13}
14
15impl GrpcPayload {
16    /// Creates a new `GrpcPayload`.
17    pub fn new(
18        metadata: PayloadMetadata, endpoint: MetaString, service_path: MetaString, body: FrozenChunkedBytesBuffer,
19    ) -> Self {
20        GrpcPayload {
21            metadata,
22            endpoint,
23            service_path,
24            body,
25        }
26    }
27
28    /// Consumes the gRPC payload and returns the individual parts.
29    pub fn into_parts(self) -> (PayloadMetadata, MetaString, MetaString, FrozenChunkedBytesBuffer) {
30        (self.metadata, self.endpoint, self.service_path, self.body)
31    }
32
33    /// Gets a reference to the endpoint.
34    pub fn endpoint(&self) -> &str {
35        &self.endpoint
36    }
37
38    /// Gets a reference to the service path.
39    pub fn service_path(&self) -> &str {
40        &self.service_path
41    }
42
43    /// Gets a reference to the body.
44    pub fn body(&self) -> &FrozenChunkedBytesBuffer {
45        &self.body
46    }
47
48    /// Gets a reference to the metadata.
49    pub fn metadata(&self) -> &PayloadMetadata {
50        &self.metadata
51    }
52}