Skip to main content

serialize_command

Function serialize_command 

Source
pub fn serialize_command(cmd: &Command) -> Result<Vec<u8>, Error>
Expand description

Serialize a client command to a format that can be sent to the daemon.

This uses the [rmp_serde] crate under the hood.

ยงExamples

Connect to the daemon and immediately disconnect.

let conn = connect(DEFAULT_SOCKET_NAME, &SocketType::default()).unwrap();
let mut conn = BufReader::new(conn);
let cmd = serialize_command(&Command::Disconnect).unwrap();
conn.get_mut().write_all(&cmd).unwrap();