Skip to content

Commit

Permalink
a way to replicate (more proto semantic than clone) for readprov
Browse files Browse the repository at this point in the history
  • Loading branch information
cheme committed Oct 26, 2017
1 parent 7f6a160 commit 91499d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/full.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,16 @@ impl<TT : GenTunnelTraits> TunnelNoRep for Full<TT> {
}
impl<TT : GenTunnelTraits> TunnelReadProv for FullReadProv<TT> {
type T = Full<TT>;

fn new_tunnel_read_prov (&self) -> Self {
FullReadProv {
me : self.me.clone(),
limiter_proto_r : self.limiter_proto_r.clone(),
sym_prov : self.sym_prov.clone(),
_p : PhantomData,
}
}

fn new_reader (&mut self) -> <Self::T as TunnelNoRep>::TR {
let s = self.me.new_shadr();
FullR {
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ pub trait TunnelNoRep : Sized {
/// Can be use directly with a read stream without accessing a central tunnel impl.
pub trait TunnelReadProv {
type T : TunnelNoRep;
fn new_tunnel_read_prov (&self) -> Self;
fn new_reader (&mut self) -> <Self::T as TunnelNoRep>::TR;
/// same as tunnel dest reader but not mandatory (for instance we do not want to share cache
/// informations)
Expand Down
1 change: 1 addition & 0 deletions src/nope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ impl<P : Peer> TunnelReadProv for TunnelNope<P> {
type T = Self;
fn new_reader (&mut self) -> <Self::T as TunnelNoRep>::TR { Nope }
fn new_dest_reader<R : Read> (&mut self, _ : <Self::T as TunnelNoRep>::TR, _ : &mut R) -> Result<Option<<Self::T as TunnelNoRep>::DR>> { Ok(Some(Nope)) }
fn new_tunnel_read_prov (&self) -> Self {TunnelNope::new()}
}


0 comments on commit 91499d0

Please sign in to comment.