MCPcopy Create free account
hub / github.com/Botloader/botloader / write_message

Function write_message

components/simpleproto/src/lib.rs:23–34  ·  view source on GitHub ↗
(
    msg: &T,
    dst: &mut (impl AsyncWrite + Unpin),
)

Source from the content-addressed store, hash-verified

21}
22
23pub async fn write_message<T: Serialize>(
24 msg: &T,
25 dst: &mut (impl AsyncWrite + Unpin),
26) -> std::io::Result<()> {
27 let encoded = serde_json::to_string(msg)?;
28 assert!(encoded.len() < 0xffffffff);
29
30 dst.write_u32(encoded.len() as u32).await?;
31 dst.write_all(encoded.as_bytes()).await?;
32
33 Ok(())
34}
35
36pub async fn message_writer<T: Serialize>(
37 dst: &mut (impl AsyncWrite + Unpin),

Callers 4

handle_broker_messageMethod · 0.85
connect_schedulerFunction · 0.85
send_eventMethod · 0.85
message_writerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected