pub enum Message {
General {
msgid: u64,
data: Option<Vec<u8>>,
},
Configuration {
msgid: u64,
gateway: String,
data: Option<Vec<u8>>,
},
Control {
msgid: u64,
srcid: u64,
action: String,
target: String,
data: Option<Vec<u8>>,
},
Ack {
msgid: u64,
ack: u64,
},
Error {
msgid: u64,
reason: String,
},
StdOut {
msgid: u64,
srcid: u64,
nodes: String,
data: Option<Vec<u8>>,
},
StdErr {
msgid: u64,
srcid: u64,
nodes: String,
data: Option<Vec<u8>>,
},
Retcode {
msgid: u64,
srcid: u64,
retcode: i32,
nodes: String,
},
Timeout {
msgid: u64,
srcid: u64,
nodes: String,
},
Routing {
msgid: u64,
srcid: u64,
event: String,
gateway: String,
targets: String,
},
Start {
msgid: u64,
},
End {
msgid: u64,
},
}Expand description
A communication message in the propagation tree protocol.
Messages are tagged unions representing the different message types exchanged between ClusterShell nodes. Each variant carries the fields specific to that message type.
Variants§
General
Generic base message.
Configuration
Configuration propagation container (ident = “CFG”). Has payload. Carries serialized topology.
Control
Action request routed through the tree (ident = “CTL”). Has payload. Carries serialized command data.
Ack
Acknowledgement message (ident = “ACK”).
Error
Error message (ident = “ERR”).
StdOut
Standard output container (ident = “OUT”). Has payload. Carries encoded output data.
StdErr
Standard error container (ident = “SER”). Has payload. Carries encoded stderr data.
Retcode
Return code container (ident = “RET”).
Timeout
Timeout notification (ident = “TIM”).
Routing
Routing notification (ident = “RTR”).
Start
Start of channel communication (ident = “CHA”).
End
End of channel communication (ident = “END”).
Implementations§
Source§impl Message
impl Message
Sourcepub fn configuration(gateway: &str) -> Self
pub fn configuration(gateway: &str) -> Self
Create a new Configuration message.
Sourcepub fn routing(event: &str, gateway: &str, targets: &str, srcid: u64) -> Self
pub fn routing(event: &str, gateway: &str, targets: &str, srcid: u64) -> Self
Create a new Routing message.
Sourcepub fn has_payload(&self) -> bool
pub fn has_payload(&self) -> bool
Whether this message type carries a payload.
Sourcepub fn set_data(&mut self, payload: Vec<u8>)
pub fn set_data(&mut self, payload: Vec<u8>)
Set the payload data (raw bytes, will be base64-encoded on serialization).
Sourcepub fn data_encode(&mut self, raw: &[u8])
pub fn data_encode(&mut self, raw: &[u8])
Encode arbitrary bytes as base64 and store as payload.
Sourcepub fn data_decode(&self) -> Result<Vec<u8>, MessageProcessingError>
pub fn data_decode(&self) -> Result<Vec<u8>, MessageProcessingError>
Decode the base64 payload back to raw bytes.
Sourcepub fn data_update(&mut self, raw: &[u8]) -> Result<(), MessageProcessingError>
pub fn data_update(&mut self, raw: &[u8]) -> Result<(), MessageProcessingError>
Append data during incremental XML parsing.
Sourcepub fn xml(&self) -> Vec<u8> ⓘ
pub fn xml(&self) -> Vec<u8> ⓘ
Serialize this message to XML bytes.
Produces output like:
<message type="CFG" msgid="0" gateway="gw1">base64payload</message>
Sourcepub fn from_attrs(
attrs: &HashMap<String, String>,
) -> Result<Message, MessageProcessingError>
pub fn from_attrs( attrs: &HashMap<String, String>, ) -> Result<Message, MessageProcessingError>
Build a message from parsed XML attributes.
The message type is selected based on the “type” attribute, and all other attributes are read according to the variant’s schema.