Skip to content

Commit

Permalink
Merge pull request #181 from jsturtevant/update-client-api
Browse files Browse the repository at this point in the history
Add new api for creating client
  • Loading branch information
lifupan authored Apr 10, 2023
2 parents ebbb58e + 6639bca commit 1851aa0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/sync/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,25 @@ impl Client {

#[cfg(unix)]
/// Initialize a new [`Client`] from raw file descriptor.
#[deprecated(since="0.8.0", note="please use `new_from_fd` instead")]
pub fn new(fd: RawFd) -> Client {
let conn = ClientConnection::new(fd);

// TODO: upgrade the API of Client::new and remove this panic for the major version release
Self::new_client(conn).unwrap_or_else(|e| {
panic!(
"client was not successfully initialized: {}", e
)
})
}

#[cfg(unix)]
/// Initialize a new [`Client`] from raw file descriptor.
pub fn new_from_fd(fd: RawFd) -> Result<Client> {
let conn = ClientConnection::new(fd);

Self::new_client(conn)
}

fn new_client(pipe_client: ClientConnection) -> Result<Client> {
let client = Arc::new(pipe_client);

Expand Down

0 comments on commit 1851aa0

Please # to comment.