Skip to content

Commit 6639bca

Browse files
committed
Add new api for creating client
When adding windows implementation the new_client call had a possibility of failing so the result was wrapped in a Result<Client>. This caused the existing api to use a unwrap_or_else and panic since we couldn't pass the result onto the user. Signed-off-by: James Sturtevant <[email protected]>
1 parent ebbb58e commit 6639bca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/sync/client.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,25 @@ impl Client {
5050

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

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

64+
#[cfg(unix)]
65+
/// Initialize a new [`Client`] from raw file descriptor.
66+
pub fn new_from_fd(fd: RawFd) -> Result<Client> {
67+
let conn = ClientConnection::new(fd);
68+
69+
Self::new_client(conn)
70+
}
71+
6472
fn new_client(pipe_client: ClientConnection) -> Result<Client> {
6573
let client = Arc::new(pipe_client);
6674

0 commit comments

Comments
 (0)