mirror of
https://github.com/zerotier/zssp.git
synced 2026-05-22 16:28:40 -07:00
fixed mistake in SendTo trait lifetimes
This commit is contained in:
@@ -305,7 +305,8 @@ pub trait Sender {
|
||||
/// send packet fragments on some socket or network interface.
|
||||
///
|
||||
/// Is implemented by `FnMut(&Arc<Session<Crypto>>) -> Option<(Sender, usize)>` closures.
|
||||
pub trait SendTo<Crypto: CryptoLayer, S: Sender> {
|
||||
pub trait SendTo<Crypto: CryptoLayer> {
|
||||
type Sender<'a>: Sender where Crypto: 'a, Self: 'a;
|
||||
/// Attempt to process and borrow the resources necessary to repeatedly send fragments of a
|
||||
/// packet to the given session.
|
||||
///
|
||||
@@ -315,7 +316,7 @@ pub trait SendTo<Crypto: CryptoLayer, S: Sender> {
|
||||
/// only called once.
|
||||
///
|
||||
/// If `None` is returned then sending to this session is cancelled.
|
||||
fn init_send<'a>(&'a mut self, session: &'a Arc<Session<Crypto>>) -> Option<(S, usize)>;
|
||||
fn init_send<'a>(&'a mut self, session: &'a Arc<Session<Crypto>>) -> Option<(Self::Sender<'a>, usize)>;
|
||||
}
|
||||
|
||||
impl<F: FnMut(&mut [u8]) -> bool> Sender for F {
|
||||
@@ -324,7 +325,8 @@ impl<F: FnMut(&mut [u8]) -> bool> Sender for F {
|
||||
}
|
||||
}
|
||||
|
||||
impl<Crypto: CryptoLayer, F: FnMut(&Arc<Session<Crypto>>) -> Option<(S, usize)>, S: Sender> SendTo<Crypto, S> for F {
|
||||
impl<Crypto: CryptoLayer, F: FnMut(&Arc<Session<Crypto>>) -> Option<(S, usize)>, S: Sender> SendTo<Crypto> for F {
|
||||
type Sender<'a> = S where Crypto: 'a, F: 'a;
|
||||
fn init_send<'a>(&'a mut self, session: &'a Arc<Session<Crypto>>) -> Option<(S, usize)> {
|
||||
self(session)
|
||||
}
|
||||
|
||||
@@ -190,12 +190,12 @@ impl<Crypto: CryptoLayer> Context<Crypto> {
|
||||
/// * `remote_address` - Whatever the remote address is, as long as you can Hash it
|
||||
/// * `incoming_fragment_buf` - Buffer containing incoming wire packet (the context takes ownership)
|
||||
/// * `output_buffer` - Buffer to receive decrypted and authenticated object data
|
||||
pub fn receive<'a, App: ApplicationLayer<Crypto>, S: Sender>(
|
||||
pub fn receive<'a, App: ApplicationLayer<Crypto>>(
|
||||
&self,
|
||||
mut app: App,
|
||||
mut send_unassociated_reply: impl Sender,
|
||||
mut send_unassociated_mtu: usize,
|
||||
mut send_to: impl SendTo<Crypto, S>,
|
||||
mut send_to: impl SendTo<Crypto>,
|
||||
remote_address: &impl Hash,
|
||||
mut incoming_fragment_buf: Crypto::IncomingPacketBuffer,
|
||||
output_buffer: impl Write,
|
||||
@@ -625,10 +625,10 @@ impl<Crypto: CryptoLayer> Context<Crypto> {
|
||||
///
|
||||
/// * `app` - Interface to application using ZSSP
|
||||
/// * `send_to` - Function to get a sender and an MTU to send something over an active session
|
||||
pub fn service<App: ApplicationLayer<Crypto>, S: Sender>(
|
||||
pub fn service<App: ApplicationLayer<Crypto>>(
|
||||
&self,
|
||||
mut app: App,
|
||||
send_to: impl SendTo<Crypto, S>,
|
||||
send_to: impl SendTo<Crypto>,
|
||||
) -> i64 {
|
||||
let current_time = app.time();
|
||||
let next_service_time = self.service_inner(app, send_to, current_time);
|
||||
@@ -652,18 +652,18 @@ impl<Crypto: CryptoLayer> Context<Crypto> {
|
||||
///
|
||||
/// * `app` - Interface to application using ZSSP
|
||||
/// * `send_to` - Function to get a sender and an MTU to send something over an active session
|
||||
pub fn service_scheduled<App: ApplicationLayer<Crypto>, S: Sender>(
|
||||
pub fn service_scheduled<App: ApplicationLayer<Crypto>>(
|
||||
&self,
|
||||
mut app: App,
|
||||
send_to: impl SendTo<Crypto, S>,
|
||||
send_to: impl SendTo<Crypto>,
|
||||
) -> i64 {
|
||||
let current_time = app.time();
|
||||
self.service_inner(app, send_to, current_time)
|
||||
}
|
||||
fn service_inner<App: ApplicationLayer<Crypto>, S: Sender>(
|
||||
fn service_inner<App: ApplicationLayer<Crypto>>(
|
||||
&self,
|
||||
mut app: App,
|
||||
mut send_to: impl SendTo<Crypto, S>,
|
||||
mut send_to: impl SendTo<Crypto>,
|
||||
current_time: i64,
|
||||
) -> i64 {
|
||||
let ctx = &self.0;
|
||||
|
||||
Reference in New Issue
Block a user