File tree Expand file tree Collapse file tree 5 files changed +25
-17
lines changed
Expand file tree Collapse file tree 5 files changed +25
-17
lines changed Original file line number Diff line number Diff line change 1616//!
1717//! ```no_run
1818//! use msg_socket::hooks::{ConnectionHook, Error, HookResult};
19- //! use tokio::io::{AsyncRead, AsyncWrite, AsyncReadExt , AsyncWriteExt};
19+ //! use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite , AsyncWriteExt};
2020//!
2121//! struct MyAuth;
2222//!
@@ -143,7 +143,9 @@ where
143143 Box :: pin ( async move {
144144 ConnectionHook :: on_connection ( & * self , io) . await . map_err ( |e| match e {
145145 Error :: Io ( io_err) => Error :: Io ( io_err) ,
146- Error :: Hook ( hook_err) => Error :: Hook ( Box :: new ( hook_err) as Box < dyn StdError + Send + Sync > ) ,
146+ Error :: Hook ( hook_err) => {
147+ Error :: Hook ( Box :: new ( hook_err) as Box < dyn StdError + Send + Sync > )
148+ }
147149 } )
148150 } )
149151 }
Original file line number Diff line number Diff line change 88//! # Example
99//!
1010//! ```no_run
11- //! use msg_socket::{RepSocket, ReqSocket};
12- //! use msg_socket::hooks::token::{ServerHook, ClientHook};
13- //! use msg_transport::tcp::Tcp;
1411//! use bytes::Bytes;
12+ //! use msg_socket::{
13+ //! RepSocket, ReqSocket,
14+ //! hooks::token::{ClientHook, ServerHook},
15+ //! };
16+ //! use msg_transport::tcp::Tcp;
1517//!
1618//! // Server side - validates incoming tokens
17- //! let rep = RepSocket::new(Tcp::default())
18- //! .with_connection_hook(ServerHook::new(|token| {
19- //! // Custom validation logic
20- //! token == b"secret"
21- //! }));
19+ //! let rep = RepSocket::new(Tcp::default()).with_connection_hook(ServerHook::new(|token| {
20+ //! // Custom validation logic
21+ //! token == b"secret"
22+ //! }));
2223//!
2324//! // Client side - sends token on connect
24- //! let req = ReqSocket::new(Tcp::default())
25- //! .with_connection_hook(ClientHook::new(Bytes::from("secret")));
25+ //! let req =
26+ //! ReqSocket::new(Tcp::default()) .with_connection_hook(ClientHook::new(Bytes::from("secret")));
2627//! ```
2728
2829use std:: io;
@@ -147,8 +148,8 @@ where
147148/// # Example
148149///
149150/// ```no_run
150- /// use msg_socket::hooks::token::ClientHook;
151151/// use bytes::Bytes;
152+ /// use msg_socket::hooks::token::ClientHook;
152153///
153154/// let hook = ClientHook::new(Bytes::from("my_secret_token"));
154155/// ```
Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ use std::{
55} ;
66
77use futures:: { Future , StreamExt , stream:: FuturesUnordered } ;
8+ use msg_common:: span:: { EnterSpan as _, SpanExt as _, WithSpan } ;
89use tokio:: { sync:: broadcast, task:: JoinSet } ;
910use tokio_util:: codec:: Framed ;
10- use msg_common:: span:: { EnterSpan as _, SpanExt as _, WithSpan } ;
1111use tracing:: { debug, error, info, warn} ;
1212
1313use super :: {
Original file line number Diff line number Diff line change @@ -27,7 +27,9 @@ pub(crate) enum ConnectionError<T: std::error::Error> {
2727
2828impl < T : std:: error:: Error + From < std:: io:: Error > > ConnectionError < T > {
2929 /// Create a ConnectionError from an erased hook error, converting Io errors to Transport.
30- pub ( crate ) fn from_erased_hook ( err : hooks:: Error < Box < dyn std:: error:: Error + Send + Sync > > ) -> Self {
30+ pub ( crate ) fn from_erased_hook (
31+ err : hooks:: Error < Box < dyn std:: error:: Error + Send + Sync > > ,
32+ ) -> Self {
3133 match err {
3234 hooks:: Error :: Io ( io_err) => Self :: Transport ( T :: from ( io_err) ) ,
3335 hooks:: Error :: Hook ( e) => Self :: Hook ( e) ,
Original file line number Diff line number Diff line change @@ -6,10 +6,13 @@ use std::{
66} ;
77
88use futures:: { Future , StreamExt } ;
9+ use msg_common:: span:: { EnterSpan as _, SpanExt as _, WithSpan } ;
910use rustc_hash:: FxHashMap ;
10- use tokio:: { sync:: mpsc:: { self , error:: TrySendError } , task:: JoinSet } ;
11+ use tokio:: {
12+ sync:: mpsc:: { self , error:: TrySendError } ,
13+ task:: JoinSet ,
14+ } ;
1115use tokio_util:: codec:: Framed ;
12- use msg_common:: span:: { EnterSpan as _, SpanExt as _, WithSpan } ;
1316use tracing:: { debug, error, info, warn} ;
1417
1518use super :: {
You can’t perform that action at this time.
0 commit comments