Skip to main content

disconnect

Function disconnect 

Source
pub fn disconnect(conn: &mut BufReader<Stream>) -> Result<(), Error>
Expand description

Disconnects from the daemon by sending the Command::Disconnect command.

This is a convenience function, its effect could be achieved using utilities already provided in this crate.

ยงExamples

let conn = connect(DEFAULT_SOCKET_NAME, &SocketType::default()).unwrap();
let mut conn = BufReader::new(conn);

// Do some stuff with the connection here...

match disconnect(&mut conn) {
    Ok(_) => eprintln!("Disconnected from the daemon!"),
    Err(e) => panic!("Could not close the daemon connection: {e}"),
}