Skip to content

Commit

Permalink
ptrs remove identity design example in favor of passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
jmwample committed Mar 13, 2024
1 parent 60d3162 commit 8269911
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 203 deletions.
Empty file removed crates/ptrs/src/ident/dialer.rs
Empty file.
50 changes: 0 additions & 50 deletions crates/ptrs/src/ident/handler.rs

This file was deleted.

Empty file removed crates/ptrs/src/ident/listener.rs
Empty file.
136 changes: 0 additions & 136 deletions crates/ptrs/src/ident/mod.rs

This file was deleted.

1 change: 0 additions & 1 deletion crates/ptrs/src/ident/wrapper.rs

This file was deleted.

15 changes: 8 additions & 7 deletions crates/ptrs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub use helpers::*;

pub trait PluggableTransport<T> {
type ClientBuilder: ClientBuilderByTypeInst<T>;
type ServerBuilder: ServerBuilder;
type ServerBuilder: ServerBuilder<T>;
// type Client: ClientTransport<T, E>;
// type Server: ServerTransport<T>;

Expand Down Expand Up @@ -97,16 +97,16 @@ pub trait ClientTransport<InRW, InErr> {
pub trait ServerTransport<InRW> {
type OutRW;
type OutErr: std::error::Error;
type Builder: ServerBuilder;
type Builder: ServerBuilder<InRW>;

/// Create/accept a connection for the pluggable transport client using the
/// provided (pre-existing/pre-connected) Read/Write object as the
/// underlying socket.
fn reveal(&self, io: InRW) -> Pin<F<Self::OutRW, Self::OutErr>>;
}

pub trait ServerBuilder: Default {
type ServerPT;
pub trait ServerBuilder<T>: Default {
type ServerPT: ServerTransport<T>;
type Error: std::error::Error;
type Transport;

Expand Down Expand Up @@ -139,9 +139,10 @@ pub trait ServerBuilder: Default {
}

/// Server Transport trait2 - try using futures instead of actual objects
// This doesn't work because it requires the listener object that was used
// to create the `input` Future must live for `'static` for the future to
// be valid, but that can't be guaranteed and is difficult to work with.
///
/// This doesn't work because it requires the listener object that was used
/// to create the `input` Future must live for `'static` for the future to
/// be valid, but that can't be guaranteed and is difficult to work with.
pub trait ServerTransport2<InRW, InErr> {
type OutRW;
type OutErr: std::error::Error;
Expand Down
20 changes: 11 additions & 9 deletions crates/ptrs/src/passthrough.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ where
#[derive(Debug, Default)]
pub struct BuilderS {}

impl ServerBuilder for BuilderS {
impl<T: Send + 'static> ServerBuilder<T> for BuilderS {
type Error = std::io::Error;
type ServerPT = Passthrough;
type Transport = Passthrough;
Expand Down Expand Up @@ -184,7 +184,7 @@ impl Passthrough {
mod design_tests {

use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt},
net::TcpStream,
};
use tracing::info;
Expand Down Expand Up @@ -456,6 +456,7 @@ mod design_tests {
Box<dyn std::error::Error>,
>
where
T: AsyncRead + AsyncWrite + Send,
B: ClientBuilderByTypeInst<T>,
B::ClientPT: ClientTransport<T, E>,
B::Error: std::error::Error + 'static,
Expand Down Expand Up @@ -520,17 +521,17 @@ mod design_tests {
) -> Result<
Pin<
FutureResult<
<<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder>::ServerPT as ServerTransport<T>>::OutRW,
<<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder>::ServerPT as ServerTransport<T>>::OutErr,
<<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder<T>>::ServerPT as ServerTransport<T>>::OutRW,
<<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder<T>>::ServerPT as ServerTransport<T>>::OutErr,
>,
>,
Box<dyn std::error::Error>,
>
where
P: PluggableTransport<T>,
P::ClientBuilder: ClientBuilderByTypeInst<T>,
<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder>::ServerPT: ServerTransport<T>,
<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder>::Error: std::error::Error + 'static,
<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder<T>>::ServerPT: ServerTransport<T>,
<<P as PluggableTransport<T>>::ServerBuilder as ServerBuilder<T>>::Error: std::error::Error + 'static,
E: std::error::Error + 'static,
{
Ok(P::server_builder()
Expand Down Expand Up @@ -599,14 +600,15 @@ mod design_tests {
) -> Result<
Pin<
FutureResult<
<<B as ServerBuilder>::ServerPT as ServerTransport<T>>::OutRW,
<<B as ServerBuilder>::ServerPT as ServerTransport<T>>::OutErr,
<<B as ServerBuilder<T>>::ServerPT as ServerTransport<T>>::OutRW,
<<B as ServerBuilder<T>>::ServerPT as ServerTransport<T>>::OutErr,
>,
>,
Box<dyn std::error::Error>,
>
where
B: ServerBuilder,
T: AsyncRead + AsyncWrite + Send,
B: ServerBuilder<T>,
B::ServerPT: ServerTransport<T>,
B::Error: std::error::Error + 'static,
{
Expand Down

0 comments on commit 8269911

Please sign in to comment.