@@ -254,236 +254,3 @@ where
254254 }
255255 }
256256}
257-
258- #[ cfg( test) ]
259- mod tests {
260- use http_body:: Body ;
261-
262- use super :: { Builder , Connection , SendRequest } ;
263- use crate :: core:: {
264- error:: BoxError ,
265- rt:: { Read , Write , bounds:: Http2ClientConnExec } ,
266- } ;
267-
268- pub async fn handshake < E , T , B > (
269- exec : E ,
270- io : T ,
271- ) -> crate :: core:: Result < ( SendRequest < B > , Connection < T , B , E > ) >
272- where
273- T : Read + Write + Unpin ,
274- B : Body + ' static ,
275- B :: Data : Send ,
276- B :: Error : Into < BoxError > ,
277- E : Http2ClientConnExec < B , T > + Unpin + Clone ,
278- {
279- Builder :: new ( exec) . handshake ( io) . await
280- }
281-
282- #[ tokio:: test]
283- #[ ignore] // only compilation is checked
284- async fn send_sync_executor_of_non_send_futures ( ) {
285- #[ derive( Clone ) ]
286- struct LocalTokioExecutor ;
287-
288- impl < F > crate :: core:: rt:: Executor < F > for LocalTokioExecutor
289- where
290- F : std:: future:: Future + ' static , // not requiring `Send`
291- {
292- fn execute ( & self , fut : F ) {
293- // This will spawn into the currently running `LocalSet`.
294- tokio:: task:: spawn_local ( fut) ;
295- }
296- }
297-
298- #[ allow( unused) ]
299- async fn run ( io : impl crate :: core:: rt:: Read + crate :: core:: rt:: Write + Unpin + ' static ) {
300- let ( _sender, conn) =
301- handshake :: < _ , _ , http_body_util:: Empty < bytes:: Bytes > > ( LocalTokioExecutor , io)
302- . await
303- . unwrap ( ) ;
304-
305- tokio:: task:: spawn_local ( async move {
306- conn. await . unwrap ( ) ;
307- } ) ;
308- }
309- }
310-
311- #[ tokio:: test]
312- #[ ignore] // only compilation is checked
313- async fn not_send_not_sync_executor_of_not_send_futures ( ) {
314- #[ derive( Clone ) ]
315- struct LocalTokioExecutor {
316- _x : std:: marker:: PhantomData < std:: rc:: Rc < ( ) > > ,
317- }
318-
319- impl < F > crate :: core:: rt:: Executor < F > for LocalTokioExecutor
320- where
321- F : std:: future:: Future + ' static , // not requiring `Send`
322- {
323- fn execute ( & self , fut : F ) {
324- // This will spawn into the currently running `LocalSet`.
325- tokio:: task:: spawn_local ( fut) ;
326- }
327- }
328-
329- #[ allow( unused) ]
330- async fn run ( io : impl crate :: core:: rt:: Read + crate :: core:: rt:: Write + Unpin + ' static ) {
331- let ( _sender, conn) = handshake :: < _ , _ , http_body_util:: Empty < bytes:: Bytes > > (
332- LocalTokioExecutor {
333- _x : Default :: default ( ) ,
334- } ,
335- io,
336- )
337- . await
338- . unwrap ( ) ;
339-
340- tokio:: task:: spawn_local ( async move {
341- conn. await . unwrap ( ) ;
342- } ) ;
343- }
344- }
345-
346- #[ tokio:: test]
347- #[ ignore] // only compilation is checked
348- async fn send_not_sync_executor_of_not_send_futures ( ) {
349- #[ derive( Clone ) ]
350- struct LocalTokioExecutor {
351- _x : std:: marker:: PhantomData < std:: cell:: Cell < ( ) > > ,
352- }
353-
354- impl < F > crate :: core:: rt:: Executor < F > for LocalTokioExecutor
355- where
356- F : std:: future:: Future + ' static , // not requiring `Send`
357- {
358- fn execute ( & self , fut : F ) {
359- // This will spawn into the currently running `LocalSet`.
360- tokio:: task:: spawn_local ( fut) ;
361- }
362- }
363-
364- #[ allow( unused) ]
365- async fn run ( io : impl crate :: core:: rt:: Read + crate :: core:: rt:: Write + Unpin + ' static ) {
366- let ( _sender, conn) = handshake :: < _ , _ , http_body_util:: Empty < bytes:: Bytes > > (
367- LocalTokioExecutor {
368- _x : Default :: default ( ) ,
369- } ,
370- io,
371- )
372- . await
373- . unwrap ( ) ;
374-
375- tokio:: task:: spawn_local ( async move {
376- conn. await . unwrap ( ) ;
377- } ) ;
378- }
379- }
380-
381- #[ tokio:: test]
382- #[ ignore] // only compilation is checked
383- async fn send_sync_executor_of_send_futures ( ) {
384- #[ derive( Clone ) ]
385- struct TokioExecutor ;
386-
387- impl < F > crate :: core:: rt:: Executor < F > for TokioExecutor
388- where
389- F : std:: future:: Future + ' static + Send ,
390- F :: Output : Send + ' static ,
391- {
392- fn execute ( & self , fut : F ) {
393- tokio:: task:: spawn ( fut) ;
394- }
395- }
396-
397- #[ allow( unused) ]
398- async fn run (
399- io : impl crate :: core:: rt:: Read + crate :: core:: rt:: Write + Send + Unpin + ' static ,
400- ) {
401- let ( _sender, conn) =
402- handshake :: < _ , _ , http_body_util:: Empty < bytes:: Bytes > > ( TokioExecutor , io)
403- . await
404- . unwrap ( ) ;
405-
406- tokio:: task:: spawn ( async move {
407- conn. await . unwrap ( ) ;
408- } ) ;
409- }
410- }
411-
412- #[ tokio:: test]
413- #[ ignore] // only compilation is checked
414- async fn not_send_not_sync_executor_of_send_futures ( ) {
415- #[ derive( Clone ) ]
416- struct TokioExecutor {
417- // !Send, !Sync
418- _x : std:: marker:: PhantomData < std:: rc:: Rc < ( ) > > ,
419- }
420-
421- impl < F > crate :: core:: rt:: Executor < F > for TokioExecutor
422- where
423- F : std:: future:: Future + ' static + Send ,
424- F :: Output : Send + ' static ,
425- {
426- fn execute ( & self , fut : F ) {
427- tokio:: task:: spawn ( fut) ;
428- }
429- }
430-
431- #[ allow( unused) ]
432- async fn run (
433- io : impl crate :: core:: rt:: Read + crate :: core:: rt:: Write + Send + Unpin + ' static ,
434- ) {
435- let ( _sender, conn) = handshake :: < _ , _ , http_body_util:: Empty < bytes:: Bytes > > (
436- TokioExecutor {
437- _x : Default :: default ( ) ,
438- } ,
439- io,
440- )
441- . await
442- . unwrap ( ) ;
443-
444- tokio:: task:: spawn_local ( async move {
445- // can't use spawn here because when executor is !Send
446- conn. await . unwrap ( ) ;
447- } ) ;
448- }
449- }
450-
451- #[ tokio:: test]
452- #[ ignore] // only compilation is checked
453- async fn send_not_sync_executor_of_send_futures ( ) {
454- #[ derive( Clone ) ]
455- struct TokioExecutor {
456- // !Sync
457- _x : std:: marker:: PhantomData < std:: cell:: Cell < ( ) > > ,
458- }
459-
460- impl < F > crate :: core:: rt:: Executor < F > for TokioExecutor
461- where
462- F : std:: future:: Future + ' static + Send ,
463- F :: Output : Send + ' static ,
464- {
465- fn execute ( & self , fut : F ) {
466- tokio:: task:: spawn ( fut) ;
467- }
468- }
469-
470- #[ allow( unused) ]
471- async fn run (
472- io : impl crate :: core:: rt:: Read + crate :: core:: rt:: Write + Send + Unpin + ' static ,
473- ) {
474- let ( _sender, conn) = handshake :: < _ , _ , http_body_util:: Empty < bytes:: Bytes > > (
475- TokioExecutor {
476- _x : Default :: default ( ) ,
477- } ,
478- io,
479- )
480- . await
481- . unwrap ( ) ;
482-
483- tokio:: task:: spawn_local ( async move {
484- // can't use spawn here because when executor is !Send
485- conn. await . unwrap ( ) ;
486- } ) ;
487- }
488- }
489- }
0 commit comments