@@ -18,8 +18,9 @@ use rustls_pemfile::{certs, crls, pkcs8_private_keys, rsa_private_keys};
18
18
use crate :: error:: { map_error, rustls_result} ;
19
19
use crate :: rslice:: { rustls_slice_bytes, rustls_str} ;
20
20
use crate :: {
21
- ffi_panic_boundary, try_box_from_ptr, try_mut_from_ptr, try_ref_from_ptr, try_slice,
22
- ArcCastPtr , BoxCastPtr , CastConstPtr , CastPtr ,
21
+ ffi_panic_boundary, free_arc, to_arc_const_ptr, to_boxed_mut_ptr, try_box_from_ptr,
22
+ try_mut_from_ptr, try_ref_from_ptr, try_slice, Castable , OwnershipArc , OwnershipBox ,
23
+ OwnershipRef ,
23
24
} ;
24
25
use rustls_result:: { AlreadyUsed , NullParameter } ;
25
26
@@ -33,7 +34,8 @@ pub struct rustls_certificate {
33
34
_private : [ u8 ; 0 ] ,
34
35
}
35
36
36
- impl CastPtr for rustls_certificate {
37
+ impl Castable for rustls_certificate {
38
+ type Ownership = OwnershipRef ;
37
39
type RustType = Certificate ;
38
40
}
39
41
@@ -66,7 +68,8 @@ pub struct rustls_supported_ciphersuite {
66
68
_private : [ u8 ; 0 ] ,
67
69
}
68
70
69
- impl CastPtr for rustls_supported_ciphersuite {
71
+ impl Castable for rustls_supported_ciphersuite {
72
+ type Ownership = OwnershipRef ;
70
73
type RustType = SupportedCipherSuite ;
71
74
}
72
75
@@ -262,12 +265,11 @@ pub struct rustls_certified_key {
262
265
_private : [ u8 ; 0 ] ,
263
266
}
264
267
265
- impl CastPtr for rustls_certified_key {
268
+ impl Castable for rustls_certified_key {
269
+ type Ownership = OwnershipArc ;
266
270
type RustType = CertifiedKey ;
267
271
}
268
272
269
- impl ArcCastPtr for rustls_certified_key { }
270
-
271
273
impl rustls_certified_key {
272
274
/// Build a `rustls_certified_key` from a certificate chain and a private key.
273
275
/// `cert_chain` must point to a buffer of `cert_chain_len` bytes, containing
@@ -366,7 +368,7 @@ impl rustls_certified_key {
366
368
} else {
367
369
new_key. ocsp = None ;
368
370
}
369
- * cloned_key_out = ArcCastPtr :: to_const_ptr ( new_key) ;
371
+ * cloned_key_out = to_arc_const_ptr ( new_key) ;
370
372
rustls_result:: Ok
371
373
}
372
374
}
@@ -380,7 +382,7 @@ impl rustls_certified_key {
380
382
#[ no_mangle]
381
383
pub extern "C" fn rustls_certified_key_free ( key : * const rustls_certified_key ) {
382
384
ffi_panic_boundary ! {
383
- rustls_certified_key :: free ( key) ;
385
+ free_arc ( key) ;
384
386
}
385
387
}
386
388
@@ -443,12 +445,11 @@ pub struct rustls_root_cert_store {
443
445
_private : [ u8 ; 0 ] ,
444
446
}
445
447
446
- impl CastPtr for rustls_root_cert_store {
448
+ impl Castable for rustls_root_cert_store {
449
+ type Ownership = OwnershipBox ;
447
450
type RustType = RootCertStore ;
448
451
}
449
452
450
- impl BoxCastPtr for rustls_root_cert_store { }
451
-
452
453
impl rustls_root_cert_store {
453
454
/// Create a rustls_root_cert_store. Caller owns the memory and must
454
455
/// eventually call rustls_root_cert_store_free. The store starts out empty.
@@ -458,7 +459,7 @@ impl rustls_root_cert_store {
458
459
pub extern "C" fn rustls_root_cert_store_new ( ) -> * mut rustls_root_cert_store {
459
460
ffi_panic_boundary ! {
460
461
let store = rustls:: RootCertStore :: empty( ) ;
461
- BoxCastPtr :: to_mut_ptr ( store)
462
+ to_boxed_mut_ptr ( store)
462
463
}
463
464
}
464
465
@@ -517,14 +518,13 @@ pub struct rustls_allow_any_authenticated_client_builder {
517
518
_private : [ u8 ; 0 ] ,
518
519
}
519
520
520
- impl CastPtr for rustls_allow_any_authenticated_client_builder {
521
- // NOTE: contained value is consumed even on error, so this can contain None. but the caller
521
+ impl Castable for rustls_allow_any_authenticated_client_builder {
522
+ type Ownership = OwnershipBox ;
523
+ // NOTE: contained value is consumed even on error, so this can contain None, but the caller
522
524
// still needs to free it
523
525
type RustType = Option < AllowAnyAuthenticatedClient > ;
524
526
}
525
527
526
- impl BoxCastPtr for rustls_allow_any_authenticated_client_builder { }
527
-
528
528
impl rustls_allow_any_authenticated_client_builder {
529
529
/// Create a new allow any authenticated client certificate verifier builder using the root store.
530
530
///
@@ -542,7 +542,7 @@ impl rustls_allow_any_authenticated_client_builder {
542
542
ffi_panic_boundary ! {
543
543
let store: & RootCertStore = try_ref_from_ptr!( store) ;
544
544
let client_cert_verifier = Some ( AllowAnyAuthenticatedClient :: new( store. clone( ) ) ) ;
545
- BoxCastPtr :: to_mut_ptr ( client_cert_verifier)
545
+ to_boxed_mut_ptr ( client_cert_verifier)
546
546
}
547
547
}
548
548
@@ -604,12 +604,11 @@ pub struct rustls_allow_any_authenticated_client_verifier {
604
604
_private : [ u8 ; 0 ] ,
605
605
}
606
606
607
- impl CastConstPtr for rustls_allow_any_authenticated_client_verifier {
607
+ impl Castable for rustls_allow_any_authenticated_client_verifier {
608
+ type Ownership = OwnershipArc ;
608
609
type RustType = AllowAnyAuthenticatedClient ;
609
610
}
610
611
611
- impl ArcCastPtr for rustls_allow_any_authenticated_client_verifier { }
612
-
613
612
impl rustls_allow_any_authenticated_client_verifier {
614
613
/// Create a new allow any authenticated client certificate verifier from a builder.
615
614
///
@@ -649,7 +648,7 @@ impl rustls_allow_any_authenticated_client_verifier {
649
648
verifier : * const rustls_allow_any_authenticated_client_verifier ,
650
649
) {
651
650
ffi_panic_boundary ! {
652
- rustls_allow_any_authenticated_client_verifier :: free ( verifier) ;
651
+ free_arc ( verifier) ;
653
652
}
654
653
}
655
654
}
@@ -661,14 +660,13 @@ pub struct rustls_allow_any_anonymous_or_authenticated_client_builder {
661
660
_private : [ u8 ; 0 ] ,
662
661
}
663
662
664
- impl CastPtr for rustls_allow_any_anonymous_or_authenticated_client_builder {
665
- // NOTE: contained value is consumed even on error, so this can contain None. but the caller
663
+ impl Castable for rustls_allow_any_anonymous_or_authenticated_client_builder {
664
+ type Ownership = OwnershipBox ;
665
+ // NOTE: contained value is consumed even on error, so this can contain None, but the caller
666
666
// still needs to free it
667
667
type RustType = Option < AllowAnyAnonymousOrAuthenticatedClient > ;
668
668
}
669
669
670
- impl BoxCastPtr for rustls_allow_any_anonymous_or_authenticated_client_builder { }
671
-
672
670
impl rustls_allow_any_anonymous_or_authenticated_client_builder {
673
671
/// Create a new allow any anonymous or authenticated client certificate verifier builder
674
672
/// using the root store.
@@ -688,7 +686,7 @@ impl rustls_allow_any_anonymous_or_authenticated_client_builder {
688
686
ffi_panic_boundary ! {
689
687
let store: & RootCertStore = try_ref_from_ptr!( store) ;
690
688
let client_cert_verifier = Some ( AllowAnyAnonymousOrAuthenticatedClient :: new( store. clone( ) ) ) ;
691
- BoxCastPtr :: to_mut_ptr ( client_cert_verifier)
689
+ to_boxed_mut_ptr ( client_cert_verifier)
692
690
}
693
691
}
694
692
@@ -753,12 +751,11 @@ pub struct rustls_allow_any_anonymous_or_authenticated_client_verifier {
753
751
_private : [ u8 ; 0 ] ,
754
752
}
755
753
756
- impl CastConstPtr for rustls_allow_any_anonymous_or_authenticated_client_verifier {
754
+ impl Castable for rustls_allow_any_anonymous_or_authenticated_client_verifier {
755
+ type Ownership = OwnershipArc ;
757
756
type RustType = AllowAnyAnonymousOrAuthenticatedClient ;
758
757
}
759
758
760
- impl ArcCastPtr for rustls_allow_any_anonymous_or_authenticated_client_verifier { }
761
-
762
759
impl rustls_allow_any_anonymous_or_authenticated_client_verifier {
763
760
/// Create a new allow any anonymous or authenticated client certificate verifier builder
764
761
/// from the builder.
@@ -799,7 +796,7 @@ impl rustls_allow_any_anonymous_or_authenticated_client_verifier {
799
796
verifier : * const rustls_allow_any_anonymous_or_authenticated_client_verifier ,
800
797
) {
801
798
ffi_panic_boundary ! {
802
- rustls_allow_any_anonymous_or_authenticated_client_verifier :: free ( verifier) ;
799
+ free_arc ( verifier) ;
803
800
}
804
801
}
805
802
}
0 commit comments