@@ -33,13 +33,8 @@ impl ChannelConnection {
3333 addr : SipAddr ,
3434 cancel_token : Option < CancellationToken > ,
3535 ) -> Result < Self > {
36- Self :: create_connection_inner (
37- incoming,
38- Outgoing :: Unbounded ( outgoing) ,
39- addr,
40- cancel_token,
41- )
42- . await
36+ Self :: create_connection_inner ( incoming, Outgoing :: Unbounded ( outgoing) , addr, cancel_token)
37+ . await
4338 }
4439
4540 pub async fn create_connection_bounded (
@@ -48,13 +43,8 @@ impl ChannelConnection {
4843 addr : SipAddr ,
4944 cancel_token : Option < CancellationToken > ,
5045 ) -> Result < Self > {
51- Self :: create_connection_inner (
52- incoming,
53- Outgoing :: Bounded ( outgoing) ,
54- addr,
55- cancel_token,
56- )
57- . await
46+ Self :: create_connection_inner ( incoming, Outgoing :: Bounded ( outgoing) , addr, cancel_token)
47+ . await
5848 }
5949
6050 async fn create_connection_inner (
@@ -143,7 +133,9 @@ mod tests {
143133 SipAddr {
144134 r#type : None ,
145135 addr : HostWithPort {
146- host : crate :: sip:: Host :: IpAddr ( std:: net:: IpAddr :: V4 ( std:: net:: Ipv4Addr :: new ( 127 , 0 , 0 , 1 ) ) ) ,
136+ host : crate :: sip:: Host :: IpAddr ( std:: net:: IpAddr :: V4 ( std:: net:: Ipv4Addr :: new (
137+ 127 , 0 , 0 , 1 ,
138+ ) ) ) ,
147139 port : Some ( 5060 . into ( ) ) ,
148140 } ,
149141 }
@@ -163,9 +155,14 @@ mod tests {
163155 async fn test_create_connection_bounded_send_receive ( ) {
164156 let ( _incoming_tx, incoming_rx) = mpsc:: unbounded_channel ( ) ;
165157 let ( outgoing_tx, mut outgoing_rx) = mpsc:: channel ( 16 ) ;
166- let conn = ChannelConnection :: create_connection_bounded ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
167- . await
168- . expect ( "create_connection_bounded" ) ;
158+ let conn = ChannelConnection :: create_connection_bounded (
159+ incoming_rx,
160+ outgoing_tx,
161+ test_sip_addr ( ) ,
162+ None ,
163+ )
164+ . await
165+ . expect ( "create_connection_bounded" ) ;
169166
170167 let msg = test_message ( ) ;
171168 conn. send ( msg) . await . expect ( "send via bounded channel" ) ;
@@ -178,9 +175,14 @@ mod tests {
178175 async fn test_try_send_on_bounded ( ) {
179176 let ( _incoming_tx, incoming_rx) = mpsc:: unbounded_channel ( ) ;
180177 let ( outgoing_tx, mut outgoing_rx) = mpsc:: channel ( 2 ) ;
181- let conn = ChannelConnection :: create_connection_bounded ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
182- . await
183- . expect ( "create_connection_bounded" ) ;
178+ let conn = ChannelConnection :: create_connection_bounded (
179+ incoming_rx,
180+ outgoing_tx,
181+ test_sip_addr ( ) ,
182+ None ,
183+ )
184+ . await
185+ . expect ( "create_connection_bounded" ) ;
184186
185187 let msg = test_message ( ) ;
186188 conn. try_send ( msg) . expect ( "try_send on bounded" ) ;
@@ -193,9 +195,10 @@ mod tests {
193195 async fn test_try_send_on_unbounded ( ) {
194196 let ( _incoming_tx, incoming_rx) = mpsc:: unbounded_channel ( ) ;
195197 let ( outgoing_tx, mut outgoing_rx) = mpsc:: unbounded_channel ( ) ;
196- let conn = ChannelConnection :: create_connection ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
197- . await
198- . expect ( "create_connection" ) ;
198+ let conn =
199+ ChannelConnection :: create_connection ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
200+ . await
201+ . expect ( "create_connection" ) ;
199202
200203 let msg = test_message ( ) ;
201204 conn. try_send ( msg) . expect ( "try_send on unbounded" ) ;
@@ -208,22 +211,35 @@ mod tests {
208211 async fn test_try_send_bounded_full ( ) {
209212 let ( _incoming_tx, incoming_rx) = mpsc:: unbounded_channel ( ) ;
210213 let ( outgoing_tx, _outgoing_rx) = mpsc:: channel ( 1 ) ;
211- let conn = ChannelConnection :: create_connection_bounded ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
212- . await
213- . expect ( "create_connection_bounded" ) ;
214+ let conn = ChannelConnection :: create_connection_bounded (
215+ incoming_rx,
216+ outgoing_tx,
217+ test_sip_addr ( ) ,
218+ None ,
219+ )
220+ . await
221+ . expect ( "create_connection_bounded" ) ;
214222
215223 conn. try_send ( test_message ( ) ) . expect ( "first send" ) ;
216224 let result = conn. try_send ( test_message ( ) ) ;
217- assert ! ( result. is_err( ) , "try_send on full bounded channel should return error" ) ;
225+ assert ! (
226+ result. is_err( ) ,
227+ "try_send on full bounded channel should return error"
228+ ) ;
218229 }
219230
220231 #[ tokio:: test]
221232 async fn test_bounded_connection_serve_loop ( ) {
222233 let ( incoming_tx, incoming_rx) = mpsc:: unbounded_channel :: < super :: super :: TransportEvent > ( ) ;
223234 let ( outgoing_tx, _outgoing_rx) = mpsc:: channel ( 16 ) ;
224- let conn = ChannelConnection :: create_connection_bounded ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
225- . await
226- . expect ( "create_connection_bounded" ) ;
235+ let conn = ChannelConnection :: create_connection_bounded (
236+ incoming_rx,
237+ outgoing_tx,
238+ test_sip_addr ( ) ,
239+ None ,
240+ )
241+ . await
242+ . expect ( "create_connection_bounded" ) ;
227243
228244 // Serve loop in background, forwarding events
229245 let ( event_tx, _event_rx) = mpsc:: unbounded_channel ( ) ;
@@ -247,9 +263,14 @@ mod tests {
247263 async fn test_bounded_serve_loop_twice_returns_error ( ) {
248264 let ( incoming_tx, incoming_rx) = mpsc:: unbounded_channel :: < super :: super :: TransportEvent > ( ) ;
249265 let ( outgoing_tx, _outgoing_rx) = mpsc:: channel ( 16 ) ;
250- let conn = ChannelConnection :: create_connection_bounded ( incoming_rx, outgoing_tx, test_sip_addr ( ) , None )
251- . await
252- . expect ( "create_connection_bounded" ) ;
266+ let conn = ChannelConnection :: create_connection_bounded (
267+ incoming_rx,
268+ outgoing_tx,
269+ test_sip_addr ( ) ,
270+ None ,
271+ )
272+ . await
273+ . expect ( "create_connection_bounded" ) ;
253274
254275 // Drop the sender so the incoming channel is closed
255276 drop ( incoming_tx) ;
0 commit comments