pub struct Frame {
pub command: String,
pub headers: Vec<(String, String)>,
pub body: Vec<u8>,
}Expand description
A simple representation of a STOMP frame.
Frame contains the command (e.g. “SEND”, “MESSAGE”), an ordered list
of headers (key/value pairs) and the raw body bytes.
Fields§
§command: StringSTOMP command (e.g. CONNECT, SEND, SUBSCRIBE)
headers: Vec<(String, String)>Ordered headers as (key, value) pairs
body: Vec<u8>Raw body bytes
Implementations§
Source§impl Frame
impl Frame
Sourcepub fn new(command: impl Into<String>) -> Self
pub fn new(command: impl Into<String>) -> Self
Create a new frame with the given command and empty headers/body.
Parameters
command: the STOMP command name (for example,"SEND"or"SUBSCRIBE"). Accepts any type convertible intoString.
Sourcepub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn header(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a header (builder style).
Parameters
key: header name (converted toString).value: header value (converted toString).
Returns the mutated Frame allowing builder-style chaining.
Sourcepub fn set_body(self, body: impl Into<Vec<u8>>) -> Self
pub fn set_body(self, body: impl Into<Vec<u8>>) -> Self
Set the frame body (builder style).
Parameters
body: raw body bytes. Accepts any type convertible intoVec<u8>.
Returns the mutated Frame allowing builder-style chaining.
Sourcepub fn receipt(self, id: impl Into<String>) -> Self
pub fn receipt(self, id: impl Into<String>) -> Self
Request a receipt for this frame (builder style).
When sent, the server will respond with a RECEIPT frame containing
the same receipt ID. Use this with Connection::wait_for_receipt()
to confirm delivery.
Parameters
id: the receipt identifier. Must be unique per connection.
Returns the mutated Frame allowing builder-style chaining.
§Example
let frame = Frame::new("SEND")
.header("destination", "/queue/test")
.receipt("msg-001")
.set_body(b"hello".to_vec());Sourcepub fn get_header(&self, key: &str) -> Option<&str>
pub fn get_header(&self, key: &str) -> Option<&str>
Get the value of a header by name.
Returns the first header value matching the given key (case-sensitive),
or None if no such header exists.