@@ -3,6 +3,7 @@ use std::ffi::{CStr, CString};
33use std:: fmt;
44use std:: io:: { self , SeekFrom , Write } ;
55use std:: path:: Path ;
6+ use std:: ptr;
67use std:: slice;
78use std:: str;
89use std:: time:: Duration ;
@@ -306,13 +307,12 @@ pub fn debug(kind: InfoType, data: &[u8]) {
306307 InfoType :: HeaderOut => ">" ,
307308 InfoType :: DataIn | InfoType :: SslDataIn => "{" ,
308309 InfoType :: DataOut | InfoType :: SslDataOut => "}" ,
309- InfoType :: __Nonexhaustive => " " ,
310310 } ;
311311 let mut out = out. lock ( ) ;
312312 drop ( write ! ( out, "{} " , prefix) ) ;
313313 match str:: from_utf8 ( data) {
314314 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( ) ) ) ,
316316 }
317317}
318318
@@ -392,6 +392,7 @@ struct Inner<H> {
392392unsafe impl < H : Send > Send for Inner < H > { }
393393
394394/// Possible proxy types that libcurl currently understands.
395+ #[ non_exhaustive]
395396#[ allow( missing_docs) ]
396397#[ derive( Debug , Clone , Copy ) ]
397398pub enum ProxyType {
@@ -401,43 +402,31 @@ pub enum ProxyType {
401402 Socks5 = curl_sys:: CURLPROXY_SOCKS5 as isize ,
402403 Socks4a = curl_sys:: CURLPROXY_SOCKS4A as isize ,
403404 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,
409405}
410406
411407/// Possible conditions for the `time_condition` method.
408+ #[ non_exhaustive]
412409#[ allow( missing_docs) ]
413410#[ derive( Debug , Clone , Copy ) ]
414411pub enum TimeCondition {
415412 None = curl_sys:: CURL_TIMECOND_NONE as isize ,
416413 IfModifiedSince = curl_sys:: CURL_TIMECOND_IFMODSINCE as isize ,
417414 IfUnmodifiedSince = curl_sys:: CURL_TIMECOND_IFUNMODSINCE as isize ,
418415 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,
424416}
425417
426418/// Possible values to pass to the `ip_resolve` method.
419+ #[ non_exhaustive]
427420#[ allow( missing_docs) ]
428421#[ derive( Debug , Clone , Copy ) ]
429422pub enum IpResolve {
430423 V4 = curl_sys:: CURL_IPRESOLVE_V4 as isize ,
431424 V6 = curl_sys:: CURL_IPRESOLVE_V6 as isize ,
432425 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 ,
438426}
439427
440428/// Possible values to pass to the `http_version` method.
429+ #[ non_exhaustive]
441430#[ derive( Debug , Clone , Copy ) ]
442431pub enum HttpVersion {
443432 /// We don't care what http version to use, and we'd like the library to
@@ -472,14 +461,10 @@ pub enum HttpVersion {
472461 ///
473462 /// (Added in CURL 7.66.0)
474463 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 ,
480464}
481465
482466/// Possible values to pass to the `ssl_version` and `ssl_min_max_version` method.
467+ #[ non_exhaustive]
483468#[ allow( missing_docs) ]
484469#[ derive( Debug , Clone , Copy ) ]
485470pub enum SslVersion {
@@ -491,14 +476,10 @@ pub enum SslVersion {
491476 Tlsv11 = curl_sys:: CURL_SSLVERSION_TLSv1_1 as isize ,
492477 Tlsv12 = curl_sys:: CURL_SSLVERSION_TLSv1_2 as isize ,
493478 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 ,
499479}
500480
501481/// Possible return values from the `seek_function` callback.
482+ #[ non_exhaustive]
502483#[ derive( Debug , Clone , Copy ) ]
503484pub enum SeekResult {
504485 /// Indicates that the seek operation was a success
@@ -511,15 +492,11 @@ pub enum SeekResult {
511492 /// Indicates that although the seek failed libcurl should attempt to keep
512493 /// working if possible (for example "seek" through reading).
513494 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 ,
519495}
520496
521497/// Possible data chunks that can be witnessed as part of the `debug_function`
522498/// callback.
499+ #[ non_exhaustive]
523500#[ derive( Debug , Clone , Copy ) ]
524501pub enum InfoType {
525502 /// The data is informational text.
@@ -542,38 +519,25 @@ pub enum InfoType {
542519
543520 /// The data is SSL/TLS (binary) data sent to the peer.
544521 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,
550522}
551523
552524/// Possible error codes that can be returned from the `read_function` callback.
525+ #[ non_exhaustive]
553526#[ derive( Debug ) ]
554527pub enum ReadError {
555528 /// Indicates that the connection should be aborted immediately
556529 Abort ,
557530
558531 /// Indicates that reading should be paused until `unpause` is called.
559532 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,
565533}
566534
567535/// Possible error codes that can be returned from the `write_function` callback.
536+ #[ non_exhaustive]
568537#[ derive( Debug ) ]
569538pub enum WriteError {
570539 /// Indicates that reading should be paused until `unpause` is called.
571540 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,
577541}
578542
579543/// Options for `.netrc` parsing.
@@ -623,17 +587,17 @@ impl<H: Handler> Easy2<H> {
623587 assert ! ( !handle. is_null( ) ) ;
624588 let mut ret = Easy2 {
625589 inner : Box :: new ( Inner {
626- handle : handle ,
590+ handle,
627591 header_list : None ,
628592 resolve_list : None ,
629593 connect_to_list : None ,
630594 form : None ,
631595 error_buf : RefCell :: new ( vec ! [ 0 ; curl_sys:: CURL_ERROR_SIZE ] ) ,
632- handler : handler ,
596+ handler,
633597 } ) ,
634598 } ;
635599 ret. default_configure ( ) ;
636- return ret;
600+ ret
637601 }
638602 }
639603
@@ -2658,7 +2622,7 @@ impl<H> Easy2<H> {
26582622 /// if the option isn't supported.
26592623 pub fn cookies ( & mut self ) -> Result < List , Error > {
26602624 unsafe {
2661- let mut list = 0 as * mut _ ;
2625+ let mut list = ptr :: null_mut ( ) ;
26622626 let rc = curl_sys:: curl_easy_getinfo (
26632627 self . inner . handle ,
26642628 curl_sys:: CURLINFO_COOKIELIST ,
@@ -2721,7 +2685,7 @@ impl<H> Easy2<H> {
27212685 pub fn perform ( & self ) -> Result < ( ) , Error > {
27222686 let ret = unsafe { self . cvt ( curl_sys:: curl_easy_perform ( self . inner . handle ) ) } ;
27232687 panic:: propagate ( ) ;
2724- return ret;
2688+ ret
27252689 }
27262690
27272691 /// Unpause reading on a connection.
@@ -2781,7 +2745,7 @@ impl<H> Easy2<H> {
27812745 let ret = str:: from_utf8 ( CStr :: from_ptr ( p) . to_bytes ( ) ) . unwrap ( ) ;
27822746 let ret = String :: from ( ret) ;
27832747 curl_sys:: curl_free ( p as * mut _ ) ;
2784- return ret;
2748+ ret
27852749 }
27862750 }
27872751
@@ -2815,7 +2779,7 @@ impl<H> Easy2<H> {
28152779 let slice = slice:: from_raw_parts ( p as * const u8 , len as usize ) ;
28162780 let ret = slice. to_vec ( ) ;
28172781 curl_sys:: curl_free ( p as * mut _ ) ;
2818- return ret;
2782+ ret
28192783 }
28202784 }
28212785
@@ -3060,9 +3024,7 @@ extern "C" fn write_cb<H: Handler>(
30603024 let input = slice:: from_raw_parts ( ptr as * const u8 , size * nmemb) ;
30613025 match ( * ( data as * mut Inner < H > ) ) . handler . write ( input) {
30623026 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 ,
30663028 }
30673029 } )
30683030 . unwrap_or ( !0 )
@@ -3079,9 +3041,7 @@ extern "C" fn read_cb<H: Handler>(
30793041 match ( * ( data as * mut Inner < H > ) ) . handler . read ( input) {
30803042 Ok ( s) => s,
30813043 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 ,
30853045 }
30863046 } )
30873047 . unwrap_or ( !0 )
@@ -3145,7 +3105,7 @@ extern "C" fn debug_cb<H: Handler>(
31453105 } ;
31463106 ( * ( userptr as * mut Inner < H > ) ) . handler . debug ( kind, data)
31473107 } ) ;
3148- return 0 ;
3108+ 0
31493109}
31503110
31513111extern "C" fn ssl_ctx_cb < H : Handler > (
0 commit comments