pub struct Channel {
pub opened: bool,
pub setup: bool,
pub initiator: bool,
pub closed: bool,
pub xml_reader: XmlReader,
pub outbox: VecDeque<Vec<u8>>,
}Expand description
Communication channel between nodes in the propagation tree.
A Channel manages XML-based message exchange over a transport (typically
an SSH pipe). It uses an XmlReader for incoming messages and XML
generation for outgoing messages.
Fields§
§opened: boolWhether the channel has been opened (received StartMessage).
setup: boolWhether the channel setup is complete (received ACK to config).
initiator: boolWhether this end initiated the channel.
closed: boolWhether the channel has been closed (fatal error or EndMessage).
xml_reader: XmlReaderThe XML reader for parsing incoming data.
outbox: VecDeque<Vec<u8>>Outgoing message buffer.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn feed(
&mut self,
data: &str,
) -> Result<Vec<Message>, MessageProcessingError>
pub fn feed( &mut self, data: &str, ) -> Result<Vec<Message>, MessageProcessingError>
Feed incoming data to the XML reader and return any parsed messages.
Sourcepub fn take_outgoing(&mut self) -> Option<Vec<u8>>
pub fn take_outgoing(&mut self) -> Option<Vec<u8>>
Take the next outgoing message from the outbox.
Sourcepub fn handle_channel_error(
&mut self,
node: &str,
err: &MessageProcessingError,
) -> Option<Message>
pub fn handle_channel_error( &mut self, node: &str, err: &MessageProcessingError, ) -> Option<Message>
Report a channel-level error, mirroring upstream Channel.ev_read’s
SAXParseException / MessageProcessingError handlers (commit 6f45bf5).
- initiator side: returns a synthetic stderr
Message(identSER, srcid 0, nodes =node) whose payload is the error text encoded withENCODING. Upstream passes bytes here; passing the error text through unchanged (instead of a str/bytes mix) is what fixed the TypeError that hid the original error. The caller delivers the returned message to its ownrecv()path, exactly like upstream’sself.recv(StdErrMessage(node, text.encode(ENCODING))). For a parse error the bare parser message is used (upstream sendsex.getMessage(), e.g. “not well-formed (invalid token)”). - target side: enqueues an Error message back to the peer
(“Parse error: %s” for parse errors, the plain error text otherwise)
and returns
None.
In both cases the channel is closed: upstream treats these as fatal channel errors. This function is infallible — the error-reporting path must never itself fail (6f45bf5).