Skip to content

Commit

Permalink
Fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip-NLnetLabs committed Aug 10, 2023
1 parent 2119f2d commit 39eac2a
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 26 deletions.
8 changes: 5 additions & 3 deletions src/net/client/multi_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,8 @@ impl<Octs: Clone + Composer + Debug + OctetsBuilder + Send + 'static>
query_msg: &'a mut MessageBuilder<
StaticCompressor<StreamTarget<Octs>>,
>,
) -> Pin<Box<dyn Future<Output = Result<Query<Octs>, Error>> + Send + '_>> {
) -> Pin<Box<dyn Future<Output = Result<Query<Octs>, Error>> + Send + '_>>
{
return Box::pin(self.query_impl(query_msg));
}
}
Expand Down Expand Up @@ -680,8 +681,9 @@ impl<
{
fn get_result(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>>
{
) -> Pin<
Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>,
> {
Box::pin(self.get_result_impl())
}
}
Expand Down
21 changes: 17 additions & 4 deletions src/net/client/octet_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,13 @@ impl<Octs: AsMut<[u8]> + Clone + Composer + Debug + OctetsBuilder>
}

impl<
Octs: AsMut<[u8]> + AsRef<[u8]> + Clone + Composer + Debug + OctetsBuilder + Send,
Octs: AsMut<[u8]>
+ AsRef<[u8]>
+ Clone
+ Composer
+ Debug
+ OctetsBuilder
+ Send,
> Connection<Octs>
{
/// Constructor for [Connection].
Expand Down Expand Up @@ -822,7 +828,13 @@ impl<
}

impl<
Octs: AsMut<[u8]> + AsRef<[u8]> + Clone + Composer + Debug + OctetsBuilder + Send,
Octs: AsMut<[u8]>
+ AsRef<[u8]>
+ Clone
+ Composer
+ Debug
+ OctetsBuilder
+ Send,
> QueryMessage<Query, Octs> for Connection<Octs>
{
fn query<'a>(
Expand Down Expand Up @@ -891,8 +903,9 @@ impl Query {
impl GetResult for Query {
fn get_result(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>>
{
) -> Pin<
Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>,
> {
Box::pin(self.get_result_impl())
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/net/client/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,7 @@ pub trait GetResult {
/// This function is intended to be cancel safe.
fn get_result(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>>;
) -> Pin<
Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>,
>;
}
16 changes: 11 additions & 5 deletions src/net/client/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ impl<Octs: AsRef<[u8]> + Clone + Send> QueryMessage<Query<Octs>, Octs>
query_msg: &'a mut MessageBuilder<
StaticCompressor<StreamTarget<Octs>>,
>,
) -> Pin<Box<dyn Future<Output = Result<Query<Octs>, Error>> + Send + '_>> {
) -> Pin<Box<dyn Future<Output = Result<Query<Octs>, Error>> + Send + '_>>
{
return Box::pin(self.query_impl(query_msg));
}
}
Expand Down Expand Up @@ -168,12 +169,16 @@ impl<Octs: AsRef<[u8]> + Clone + Send> Query<Octs> {
continue;
}
QueryState::Send => {
let dgram = self.query_msg .as_target() .as_target() .as_dgram_slice();
let dgram = self
.query_msg
.as_target()
.as_target()
.as_dgram_slice();
let sent = self
.sock
.as_ref()
.expect("socket should be present")
.send( dgram)
.send(dgram)
.await
.map_err(|e| Error::UdpSend(Arc::new(e)))?;
if sent
Expand Down Expand Up @@ -264,8 +269,9 @@ impl<Octs: AsRef<[u8]> + Clone + Send> Query<Octs> {
impl<Octs: AsRef<[u8]> + Clone + Send> GetResult for Query<Octs> {
fn get_result(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>>
{
) -> Pin<
Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>,
> {
Box::pin(self.get_result_impl())
}
}
Expand Down
22 changes: 9 additions & 13 deletions src/net/client/udp_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ impl<Octs: Clone + Composer + Debug + OctetsBuilder + Send + 'static>
query_msg: &'a mut MessageBuilder<
StaticCompressor<StreamTarget<Octs>>,
>,
) -> Pin<Box<dyn Future<Output = Result<Query<Octs>, Error>> + Send + '_>> {
) -> Pin<Box<dyn Future<Output = Result<Query<Octs>, Error>> + Send + '_>>
{
return Box::pin(self.query_impl(query_msg));
}
}
Expand Down Expand Up @@ -134,11 +135,8 @@ impl<
loop {
match &mut self.state {
QueryState::StartUdpQuery => {
let mut msg = self.query_msg.clone();
let query = self
.udp_conn
.query(&mut msg)
.await?;
let mut msg = self.query_msg.clone();
let query = self.udp_conn.query(&mut msg).await?;
self.state = QueryState::GetUdpResult(query);
continue;
}
Expand All @@ -151,11 +149,8 @@ impl<
return Ok(reply);
}
QueryState::StartTcpQuery => {
let mut msg = self.query_msg.clone();
let query = self
.tcp_conn
.query(&mut msg)
.await?;
let mut msg = self.query_msg.clone();
let query = self.tcp_conn.query(&mut msg).await?;
self.state = QueryState::GetTcpResult(query);
continue;
}
Expand All @@ -181,8 +176,9 @@ impl<
{
fn get_result(
&mut self,
) -> Pin<Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>>
{
) -> Pin<
Box<dyn Future<Output = Result<Message<Bytes>, Error>> + Send + '_>,
> {
Box::pin(self.get_result_impl())
}
}
Expand Down

0 comments on commit 39eac2a

Please sign in to comment.