@@ -3,6 +3,7 @@ use std::ffi::{CStr, CString};
3
3
use std:: fmt;
4
4
use std:: io:: { self , SeekFrom , Write } ;
5
5
use std:: path:: Path ;
6
+ use std:: ptr;
6
7
use std:: slice;
7
8
use std:: str;
8
9
use std:: time:: Duration ;
@@ -306,13 +307,12 @@ pub fn debug(kind: InfoType, data: &[u8]) {
306
307
InfoType :: HeaderOut => ">" ,
307
308
InfoType :: DataIn | InfoType :: SslDataIn => "{" ,
308
309
InfoType :: DataOut | InfoType :: SslDataOut => "}" ,
309
- InfoType :: __Nonexhaustive => " " ,
310
310
} ;
311
311
let mut out = out. lock ( ) ;
312
312
drop ( write ! ( out, "{} " , prefix) ) ;
313
313
match str:: from_utf8 ( data) {
314
314
Ok ( s) => drop ( out. write_all ( s. as_bytes ( ) ) ) ,
315
- Err ( _) => drop ( write ! ( out, "({} bytes of data)\n " , data. len( ) ) ) ,
315
+ Err ( _) => drop ( writeln ! ( out, "({} bytes of data)" , data. len( ) ) ) ,
316
316
}
317
317
}
318
318
@@ -392,6 +392,7 @@ struct Inner<H> {
392
392
unsafe impl < H : Send > Send for Inner < H > { }
393
393
394
394
/// Possible proxy types that libcurl currently understands.
395
+ #[ non_exhaustive]
395
396
#[ allow( missing_docs) ]
396
397
#[ derive( Debug , Clone , Copy ) ]
397
398
pub enum ProxyType {
@@ -401,43 +402,31 @@ pub enum ProxyType {
401
402
Socks5 = curl_sys:: CURLPROXY_SOCKS5 as isize ,
402
403
Socks4a = curl_sys:: CURLPROXY_SOCKS4A as isize ,
403
404
Socks5Hostname = curl_sys:: CURLPROXY_SOCKS5_HOSTNAME as isize ,
404
-
405
- /// Hidden variant to indicate that this enum should not be matched on, it
406
- /// may grow over time.
407
- #[ doc( hidden) ]
408
- __Nonexhaustive,
409
405
}
410
406
411
407
/// Possible conditions for the `time_condition` method.
408
+ #[ non_exhaustive]
412
409
#[ allow( missing_docs) ]
413
410
#[ derive( Debug , Clone , Copy ) ]
414
411
pub enum TimeCondition {
415
412
None = curl_sys:: CURL_TIMECOND_NONE as isize ,
416
413
IfModifiedSince = curl_sys:: CURL_TIMECOND_IFMODSINCE as isize ,
417
414
IfUnmodifiedSince = curl_sys:: CURL_TIMECOND_IFUNMODSINCE as isize ,
418
415
LastModified = curl_sys:: CURL_TIMECOND_LASTMOD as isize ,
419
-
420
- /// Hidden variant to indicate that this enum should not be matched on, it
421
- /// may grow over time.
422
- #[ doc( hidden) ]
423
- __Nonexhaustive,
424
416
}
425
417
426
418
/// Possible values to pass to the `ip_resolve` method.
419
+ #[ non_exhaustive]
427
420
#[ allow( missing_docs) ]
428
421
#[ derive( Debug , Clone , Copy ) ]
429
422
pub enum IpResolve {
430
423
V4 = curl_sys:: CURL_IPRESOLVE_V4 as isize ,
431
424
V6 = curl_sys:: CURL_IPRESOLVE_V6 as isize ,
432
425
Any = curl_sys:: CURL_IPRESOLVE_WHATEVER as isize ,
433
-
434
- /// Hidden variant to indicate that this enum should not be matched on, it
435
- /// may grow over time.
436
- #[ doc( hidden) ]
437
- __Nonexhaustive = 500 ,
438
426
}
439
427
440
428
/// Possible values to pass to the `http_version` method.
429
+ #[ non_exhaustive]
441
430
#[ derive( Debug , Clone , Copy ) ]
442
431
pub enum HttpVersion {
443
432
/// We don't care what http version to use, and we'd like the library to
@@ -472,14 +461,10 @@ pub enum HttpVersion {
472
461
///
473
462
/// (Added in CURL 7.66.0)
474
463
V3 = curl_sys:: CURL_HTTP_VERSION_3 as isize ,
475
-
476
- /// Hidden variant to indicate that this enum should not be matched on, it
477
- /// may grow over time.
478
- #[ doc( hidden) ]
479
- __Nonexhaustive = 500 ,
480
464
}
481
465
482
466
/// Possible values to pass to the `ssl_version` and `ssl_min_max_version` method.
467
+ #[ non_exhaustive]
483
468
#[ allow( missing_docs) ]
484
469
#[ derive( Debug , Clone , Copy ) ]
485
470
pub enum SslVersion {
@@ -491,14 +476,10 @@ pub enum SslVersion {
491
476
Tlsv11 = curl_sys:: CURL_SSLVERSION_TLSv1_1 as isize ,
492
477
Tlsv12 = curl_sys:: CURL_SSLVERSION_TLSv1_2 as isize ,
493
478
Tlsv13 = curl_sys:: CURL_SSLVERSION_TLSv1_3 as isize ,
494
-
495
- /// Hidden variant to indicate that this enum should not be matched on, it
496
- /// may grow over time.
497
- #[ doc( hidden) ]
498
- __Nonexhaustive = 500 ,
499
479
}
500
480
501
481
/// Possible return values from the `seek_function` callback.
482
+ #[ non_exhaustive]
502
483
#[ derive( Debug , Clone , Copy ) ]
503
484
pub enum SeekResult {
504
485
/// Indicates that the seek operation was a success
@@ -511,15 +492,11 @@ pub enum SeekResult {
511
492
/// Indicates that although the seek failed libcurl should attempt to keep
512
493
/// working if possible (for example "seek" through reading).
513
494
CantSeek = curl_sys:: CURL_SEEKFUNC_CANTSEEK as isize ,
514
-
515
- /// Hidden variant to indicate that this enum should not be matched on, it
516
- /// may grow over time.
517
- #[ doc( hidden) ]
518
- __Nonexhaustive = 500 ,
519
495
}
520
496
521
497
/// Possible data chunks that can be witnessed as part of the `debug_function`
522
498
/// callback.
499
+ #[ non_exhaustive]
523
500
#[ derive( Debug , Clone , Copy ) ]
524
501
pub enum InfoType {
525
502
/// The data is informational text.
@@ -542,38 +519,25 @@ pub enum InfoType {
542
519
543
520
/// The data is SSL/TLS (binary) data sent to the peer.
544
521
SslDataOut ,
545
-
546
- /// Hidden variant to indicate that this enum should not be matched on, it
547
- /// may grow over time.
548
- #[ doc( hidden) ]
549
- __Nonexhaustive,
550
522
}
551
523
552
524
/// Possible error codes that can be returned from the `read_function` callback.
525
+ #[ non_exhaustive]
553
526
#[ derive( Debug ) ]
554
527
pub enum ReadError {
555
528
/// Indicates that the connection should be aborted immediately
556
529
Abort ,
557
530
558
531
/// Indicates that reading should be paused until `unpause` is called.
559
532
Pause ,
560
-
561
- /// Hidden variant to indicate that this enum should not be matched on, it
562
- /// may grow over time.
563
- #[ doc( hidden) ]
564
- __Nonexhaustive,
565
533
}
566
534
567
535
/// Possible error codes that can be returned from the `write_function` callback.
536
+ #[ non_exhaustive]
568
537
#[ derive( Debug ) ]
569
538
pub enum WriteError {
570
539
/// Indicates that reading should be paused until `unpause` is called.
571
540
Pause ,
572
-
573
- /// Hidden variant to indicate that this enum should not be matched on, it
574
- /// may grow over time.
575
- #[ doc( hidden) ]
576
- __Nonexhaustive,
577
541
}
578
542
579
543
/// Options for `.netrc` parsing.
@@ -623,17 +587,17 @@ impl<H: Handler> Easy2<H> {
623
587
assert ! ( !handle. is_null( ) ) ;
624
588
let mut ret = Easy2 {
625
589
inner : Box :: new ( Inner {
626
- handle : handle ,
590
+ handle,
627
591
header_list : None ,
628
592
resolve_list : None ,
629
593
connect_to_list : None ,
630
594
form : None ,
631
595
error_buf : RefCell :: new ( vec ! [ 0 ; curl_sys:: CURL_ERROR_SIZE ] ) ,
632
- handler : handler ,
596
+ handler,
633
597
} ) ,
634
598
} ;
635
599
ret. default_configure ( ) ;
636
- return ret;
600
+ ret
637
601
}
638
602
}
639
603
@@ -2658,7 +2622,7 @@ impl<H> Easy2<H> {
2658
2622
/// if the option isn't supported.
2659
2623
pub fn cookies ( & mut self ) -> Result < List , Error > {
2660
2624
unsafe {
2661
- let mut list = 0 as * mut _ ;
2625
+ let mut list = ptr :: null_mut ( ) ;
2662
2626
let rc = curl_sys:: curl_easy_getinfo (
2663
2627
self . inner . handle ,
2664
2628
curl_sys:: CURLINFO_COOKIELIST ,
@@ -2721,7 +2685,7 @@ impl<H> Easy2<H> {
2721
2685
pub fn perform ( & self ) -> Result < ( ) , Error > {
2722
2686
let ret = unsafe { self . cvt ( curl_sys:: curl_easy_perform ( self . inner . handle ) ) } ;
2723
2687
panic:: propagate ( ) ;
2724
- return ret;
2688
+ ret
2725
2689
}
2726
2690
2727
2691
/// Unpause reading on a connection.
@@ -2781,7 +2745,7 @@ impl<H> Easy2<H> {
2781
2745
let ret = str:: from_utf8 ( CStr :: from_ptr ( p) . to_bytes ( ) ) . unwrap ( ) ;
2782
2746
let ret = String :: from ( ret) ;
2783
2747
curl_sys:: curl_free ( p as * mut _ ) ;
2784
- return ret;
2748
+ ret
2785
2749
}
2786
2750
}
2787
2751
@@ -2815,7 +2779,7 @@ impl<H> Easy2<H> {
2815
2779
let slice = slice:: from_raw_parts ( p as * const u8 , len as usize ) ;
2816
2780
let ret = slice. to_vec ( ) ;
2817
2781
curl_sys:: curl_free ( p as * mut _ ) ;
2818
- return ret;
2782
+ ret
2819
2783
}
2820
2784
}
2821
2785
@@ -3060,9 +3024,7 @@ extern "C" fn write_cb<H: Handler>(
3060
3024
let input = slice:: from_raw_parts ( ptr as * const u8 , size * nmemb) ;
3061
3025
match ( * ( data as * mut Inner < H > ) ) . handler . write ( input) {
3062
3026
Ok ( s) => s,
3063
- Err ( WriteError :: Pause ) | Err ( WriteError :: __Nonexhaustive) => {
3064
- curl_sys:: CURL_WRITEFUNC_PAUSE
3065
- }
3027
+ Err ( WriteError :: Pause ) => curl_sys:: CURL_WRITEFUNC_PAUSE ,
3066
3028
}
3067
3029
} )
3068
3030
. unwrap_or ( !0 )
@@ -3079,9 +3041,7 @@ extern "C" fn read_cb<H: Handler>(
3079
3041
match ( * ( data as * mut Inner < H > ) ) . handler . read ( input) {
3080
3042
Ok ( s) => s,
3081
3043
Err ( ReadError :: Pause ) => curl_sys:: CURL_READFUNC_PAUSE ,
3082
- Err ( ReadError :: __Nonexhaustive) | Err ( ReadError :: Abort ) => {
3083
- curl_sys:: CURL_READFUNC_ABORT
3084
- }
3044
+ Err ( ReadError :: Abort ) => curl_sys:: CURL_READFUNC_ABORT ,
3085
3045
}
3086
3046
} )
3087
3047
. unwrap_or ( !0 )
@@ -3145,7 +3105,7 @@ extern "C" fn debug_cb<H: Handler>(
3145
3105
} ;
3146
3106
( * ( userptr as * mut Inner < H > ) ) . handler . debug ( kind, data)
3147
3107
} ) ;
3148
- return 0 ;
3108
+ 0
3149
3109
}
3150
3110
3151
3111
extern "C" fn ssl_ctx_cb < H : Handler > (
0 commit comments