Skip to main content
Glama
local_message.rs1.84 kB
use bytes::Bytes; use naxum::{ Extensions, Head, MessageHead, }; use si_data_nats::{ HeaderMap, Subject, }; /// Local Naxum-compatible message. #[derive(Clone, Debug)] pub struct LocalMessage { pub subject: Subject, pub headers: Option<HeaderMap>, pub payload: Bytes, } impl MessageHead for LocalMessage { fn subject(&self) -> &Subject { &self.subject } fn reply(&self) -> Option<&Subject> { None } fn headers(&self) -> Option<&HeaderMap> { self.headers.as_ref() } fn status(&self) -> Option<naxum::StatusCode> { None } fn description(&self) -> Option<&str> { None } fn length(&self) -> usize { self.payload_length() } fn payload_length(&self) -> usize { self.payload.len() } fn from_head_and_payload( head: naxum::Head, payload: Bytes, ) -> Result<(Self, naxum::Extensions), naxum::FromPartsError> where Self: Sized, { let Head { subject, reply: _, headers, status: _, description: _, length: _, extensions, } = head; Ok(( Self { subject, headers, payload, }, extensions, )) } fn into_head_and_payload(self) -> (naxum::Head, Bytes) { let Self { subject, headers, payload, } = self; ( Head { subject, reply: None, headers, status: None, description: None, length: 0, extensions: Extensions::new(), }, payload, ) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server