Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
#[throws(E)]
fn connect(ma: &MainOpts) -> Conn {
- let unix = UnixStream::connect(&ma.socket_path)
- .with_context(||ma.socket_path.clone()).context("connect to server")?;
- let chan = MgmtChannel::new(unix)?;
+ let chan = MgmtChannel::connect(&ma.socket_path)?;
let mut chan = Conn { chan };
if ma.superuser {
chan.cmd(&MC::SetSuperuser(true))?;
}
impl MgmtChannel {
+ #[throws(AE)]
+ pub fn connect(socket_path: &str) -> MgmtChannel {
+ let unix = UnixStream::connect(socket_path)
+ .with_context(||socket_path.to_owned())
+ .context("connect to server")?;
+ let chan = MgmtChannel::new(unix)?;
+ chan
+ }
+
#[throws(AE)]
pub fn new<U: IoTryClone + Read + Write + 'static>(conn: U) -> MgmtChannel {
let read = conn.try_clone().context("dup the command stream")?;