mirror of https://github.com/Trivernis/bromine.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
Rust
37 lines
1.1 KiB
Rust
pub mod tcp;
|
|
|
|
#[cfg(unix)]
|
|
pub mod unix_socket;
|
|
|
|
use crate::prelude::IPCResult;
|
|
use async_trait::async_trait;
|
|
use std::fmt::Debug;
|
|
use tokio::io::{AsyncRead, AsyncWrite};
|
|
|
|
#[async_trait]
|
|
pub trait AsyncStreamProtocolListener: Sized + Send + Sync {
|
|
type AddressType: Clone + Debug + Send + Sync;
|
|
type RemoteAddressType: Debug;
|
|
type Stream: 'static + AsyncProtocolStream<AddressType = Self::AddressType>;
|
|
|
|
async fn protocol_bind(address: Self::AddressType) -> IPCResult<Self>;
|
|
|
|
async fn protocol_accept(&self) -> IPCResult<(Self::Stream, Self::RemoteAddressType)>;
|
|
}
|
|
|
|
pub trait AsyncProtocolStreamSplit {
|
|
type OwnedSplitReadHalf: AsyncRead + Send + Sync + Unpin;
|
|
type OwnedSplitWriteHalf: AsyncWrite + Send + Sync + Unpin;
|
|
|
|
fn protocol_into_split(self) -> (Self::OwnedSplitReadHalf, Self::OwnedSplitWriteHalf);
|
|
}
|
|
|
|
#[async_trait]
|
|
pub trait AsyncProtocolStream:
|
|
AsyncRead + AsyncWrite + Send + Sync + AsyncProtocolStreamSplit + Sized
|
|
{
|
|
type AddressType: Clone + Debug + Send + Sync;
|
|
|
|
async fn protocol_connect(address: Self::AddressType) -> IPCResult<Self>;
|
|
}
|