mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2025-02-05 10:10:41 +00:00
msg_socket: return io:Error from pair() instead of Option
Change-Id: I8733794bca7a9510d5508941cbe3297a78e9923b Reviewed-on: https://chromium-review.googlesource.com/1314210 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
This commit is contained in:
parent
e0305c6533
commit
2fb61f77fe
1 changed files with 3 additions and 8 deletions
|
@ -23,13 +23,8 @@ pub use msg_on_socket_derive::*;
|
||||||
/// Create a pair of socket. Request is send in one direction while response is in the other
|
/// Create a pair of socket. Request is send in one direction while response is in the other
|
||||||
/// direction.
|
/// direction.
|
||||||
pub fn pair<Request: MsgOnSocket, Response: MsgOnSocket>(
|
pub fn pair<Request: MsgOnSocket, Response: MsgOnSocket>(
|
||||||
) -> Option<(MsgSocket<Request, Response>, MsgSocket<Response, Request>)> {
|
) -> Result<(MsgSocket<Request, Response>, MsgSocket<Response, Request>)> {
|
||||||
let (sock1, sock2) = match UnixDatagram::pair() {
|
let (sock1, sock2) = UnixDatagram::pair()?;
|
||||||
Ok((sock1, sock2)) => (sock1, sock2),
|
|
||||||
_ => {
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
let requester = MsgSocket {
|
let requester = MsgSocket {
|
||||||
sock: sock1,
|
sock: sock1,
|
||||||
_i: PhantomData,
|
_i: PhantomData,
|
||||||
|
@ -40,7 +35,7 @@ pub fn pair<Request: MsgOnSocket, Response: MsgOnSocket>(
|
||||||
_i: PhantomData,
|
_i: PhantomData,
|
||||||
_o: PhantomData,
|
_o: PhantomData,
|
||||||
};
|
};
|
||||||
Some((requester, responder))
|
Ok((requester, responder))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Bidirection sock that support both send and recv.
|
/// Bidirection sock that support both send and recv.
|
||||||
|
|
Loading…
Reference in a new issue