Trait suss::socket_shims::UnixSocketInterface
source · [−]pub trait UnixSocketInterface {
type UnixStream;
type UnixListener;
type SocketAddr;
fn unix_stream_connect<'async_trait>(
socket_path: impl 'async_trait + AsRef<Path>
) -> Pin<Box<dyn Future<Output = IoResult<Self::UnixStream>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'async_trait;
fn unix_stream_shutdown<'life0, 'async_trait>(
s: &'life0 mut Self::UnixStream
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
Self: 'async_trait;
fn unix_stream_write<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = IoResult<usize>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn unix_stream_write_all<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn unix_stream_read<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = IoResult<usize>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn unix_stream_read_exact<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
fn unix_listener_bind<'async_trait>(
path: impl 'async_trait + AsRef<Path>
) -> Pin<Box<dyn Future<Output = IoResult<Self::UnixListener>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'async_trait;
fn unix_listener_accept<'life0, 'async_trait>(
s: &'life0 mut Self::UnixListener
) -> Pin<Box<dyn Future<Output = IoResult<(Self::UnixStream, Self::SocketAddr)>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
Self: 'async_trait;
}
Expand description
Provide a unified interface to unix sockets in various points of existence. You can provide your own version of this in future if you have a runtime that is not supported.
Note that this is very unideal… In future, I am likely to do a couple things:
- Move the common interface out into a crate
- Make the trait delegate to
poll
functions and add a crapton of Future structs for the various functions, to avoid the allocations involved inasync_trait
. Maybe even see if I can’t make a macro for that.
Required Associated Types
type UnixStream
type UnixStream
Unix stream type - equivalent to std::os::unix::net::UnixStream
type UnixListener
type UnixListener
Unix listener type - equivalent to std::os::unix::net::UnixListener
type SocketAddr
type SocketAddr
Unix socket address type - equivalent to std::os::unix::net::SocketAddr
Required Methods
fn unix_stream_connect<'async_trait>(
socket_path: impl 'async_trait + AsRef<Path>
) -> Pin<Box<dyn Future<Output = IoResult<Self::UnixStream>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'async_trait,
fn unix_stream_connect<'async_trait>(
socket_path: impl 'async_trait + AsRef<Path>
) -> Pin<Box<dyn Future<Output = IoResult<Self::UnixStream>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Attempt to connect to a stream. Analogous to std::os::unix::net::UnixStream::connect
fn unix_stream_shutdown<'life0, 'async_trait>(
s: &'life0 mut Self::UnixStream
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
Self: 'async_trait,
fn unix_stream_shutdown<'life0, 'async_trait>(
s: &'life0 mut Self::UnixStream
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Attempt to shutdown a stream. Because shutting down read vs write directions is not available in all runtimes - looks @ tokio - it is necessary for this to be kind of barebones.
This will do as much shutdown as it is possible to do with the API.
fn unix_stream_write<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = IoResult<usize>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unix_stream_write<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = IoResult<usize>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Write a u8
slice to the unix stream, returning the # of actual bytes written.
Ok(0) means it prob cant take anymore.
fn unix_stream_write_all<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unix_stream_write_all<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 [u8]
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Write a u8
slice to the unix stream, repeating until it actually works all the way.
fn unix_stream_read<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = IoResult<usize>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unix_stream_read<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = IoResult<usize>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Read a u8
slice into the buffer, returning the # of actual bytes read
Ok(0) means it prob cant take anymore out of the stream for now
fn unix_stream_read_exact<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn unix_stream_read_exact<'life0, 'life1, 'async_trait>(
s: &'life0 mut Self::UnixStream,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = IoResult<()>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Read a u8
slice from the unix stream, repeating until it reads everything.
fn unix_listener_bind<'async_trait>(
path: impl 'async_trait + AsRef<Path>
) -> Pin<Box<dyn Future<Output = IoResult<Self::UnixListener>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'async_trait,
fn unix_listener_bind<'async_trait>(
path: impl 'async_trait + AsRef<Path>
) -> Pin<Box<dyn Future<Output = IoResult<Self::UnixListener>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Bind as a unix listening socket at the path
fn unix_listener_accept<'life0, 'async_trait>(
s: &'life0 mut Self::UnixListener
) -> Pin<Box<dyn Future<Output = IoResult<(Self::UnixStream, Self::SocketAddr)>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
Self: 'async_trait,
fn unix_listener_accept<'life0, 'async_trait>(
s: &'life0 mut Self::UnixListener
) -> Pin<Box<dyn Future<Output = IoResult<(Self::UnixStream, Self::SocketAddr)>> + 'async_trait>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Accept one new connection