pub struct Channel { /* private fields */ }Expand description
One end of a control channel.
Implementations§
Source§impl Channel
impl Channel
Sourcepub fn from_socket(socket: OwnedFd) -> Result<Self>
pub fn from_socket(socket: OwnedFd) -> Result<Self>
Wrap a connected channel socket handed over by a broker.
Sourcepub fn as_fd(&self) -> BorrowedFd<'_>
pub fn as_fd(&self) -> BorrowedFd<'_>
The socket, to wait on.
Sourcepub fn send<T: Serialize>(
&self,
message: &T,
fds: &[BorrowedFd<'_>],
) -> Result<(), ChannelError>
pub fn send<T: Serialize>( &self, message: &T, fds: &[BorrowedFd<'_>], ) -> Result<(), ChannelError>
Send message with fds.
Sourcepub fn recv<T: DeserializeOwned>(&self) -> Result<Received<T>, ChannelError>
pub fn recv<T: DeserializeOwned>(&self) -> Result<Received<T>, ChannelError>
Receive one message, blocking unless the socket is non-blocking.
§Errors
ChannelError::Closed at end of stream; a truncated or malformed
packet, or a receive failure (WouldBlock on a non-blocking socket
with nothing to read).
Sourcepub fn shut_down(&self) -> Result<()>
pub fn shut_down(&self) -> Result<()>
End the channel in both directions: a receive waiting on it, on any
thread, returns ChannelError::Closed, and so does every later one.
Sourcepub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
pub fn set_nonblocking(&self, nonblocking: bool) -> Result<()>
Make receives return WouldBlock instead of waiting.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Channel
impl Forget for Channel
impl Move for Channel
impl RefUnwindSafe for Channel
impl Send for Channel
impl Sync for Channel
impl Unpin for Channel
impl UnsafeUnpin for Channel
impl UnwindSafe for Channel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more