firecracker_sdk/vm/vm_socket/mod.rs
1use std::path::Path;
2
3use anyhow::Result;
4use tokio::net::UnixSocket;
5
6use crate::vm::VM;
7
8pub struct VMSocket {
9 socket: UnixSocket,
10}
11
12impl VMSocket {
13 pub fn new() -> Result<Self> {
14 Ok(Self {
15 socket: UnixSocket::new_stream()?,
16 })
17 }
18
19 pub async fn connect<P: AsRef<Path>>(self, path: P) -> Result<VM> {
20 let stream = self.socket.connect(&path).await?;
21 Ok(VM::new(stream))
22 }
23}