Skip to content

Commit f86f39c

Browse files
committed
lib: remove pub export of macros
Previously the helper macros in `src/lib.rs` were marked `macro_export`, making them part of the public API. Since these were meant to be crate internal, we also annotated the macros as `doc(hidden)` to avoid them appearing in the API docs. I suspect this was done before `pub(crate)` visibility was an option. This commit removes the `macro_export` and `doc(hidden)` attributes and uses a `pub(crate)` re-export to make the macros available to crate-internal users without making them part of the public API. Along the way this uncovered that the `try_mut_slice!` macro wasn't being used anywhere and so it is removed outright.
1 parent ab0af53 commit f86f39c

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

src/lib.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -519,8 +519,6 @@ where
519519
/// ```rust,ignore
520520
/// let config: &mut ClientConfig = try_mut_from_ptr!(builder);
521521
/// ```
522-
#[doc(hidden)]
523-
#[macro_export]
524522
macro_rules! try_mut_from_ptr {
525523
( $var:ident ) => {
526524
match $crate::try_from_mut($var) {
@@ -530,6 +528,8 @@ macro_rules! try_mut_from_ptr {
530528
};
531529
}
532530

531+
pub(crate) use try_mut_from_ptr;
532+
533533
/// Converts a const pointer to a [`Castable`] to an optional ref to the underlying
534534
/// [`Castable::RustType`]. See [`cast_const_ptr`] for more information.
535535
///
@@ -554,8 +554,6 @@ where
554554
/// ```rust, ignore
555555
/// let config: &ClientConfig = try_ref_from_ptr!(builder);
556556
/// ```
557-
#[doc(hidden)]
558-
#[macro_export]
559557
macro_rules! try_ref_from_ptr {
560558
( $var:ident ) => {
561559
match $crate::try_from($var) {
@@ -565,6 +563,8 @@ macro_rules! try_ref_from_ptr {
565563
};
566564
}
567565

566+
pub(crate) use try_ref_from_ptr;
567+
568568
/// Convert a const pointer to a [`Castable`] to an optional `Arc` over the underlying
569569
/// [`Castable::RustType`]. See [`to_arc`] for more information.
570570
///
@@ -581,8 +581,6 @@ where
581581
/// the underlying rust type using [`try_arc_from`]. Otherwise, return
582582
/// [`rustls_result::NullParameter`], or an appropriate default (`false`, `0`, `NULL`) based on the
583583
/// context. See [`try_arc_from`] for more information.
584-
#[doc(hidden)]
585-
#[macro_export]
586584
macro_rules! try_arc_from_ptr {
587585
( $var:ident ) => {
588586
match $crate::try_arc_from($var) {
@@ -592,6 +590,8 @@ macro_rules! try_arc_from_ptr {
592590
};
593591
}
594592

593+
pub(crate) use try_arc_from_ptr;
594+
595595
/// Convert a mutable pointer to a [`Castable`] to an optional `Box` over the underlying
596596
/// [`Castable::RustType`].
597597
///
@@ -608,8 +608,6 @@ where
608608
/// over the underlying rust type using [`try_box_from`]. Otherwise, return [`rustls_result::NullParameter`],
609609
/// or an appropriate default (`false`, `0`, `NULL`) based on the context. See [`try_box_from`] for
610610
/// more information.
611-
#[doc(hidden)]
612-
#[macro_export]
613611
macro_rules! try_box_from_ptr {
614612
( $var:ident ) => {
615613
match $crate::try_box_from($var) {
@@ -619,8 +617,8 @@ macro_rules! try_box_from_ptr {
619617
};
620618
}
621619

622-
#[doc(hidden)]
623-
#[macro_export]
620+
pub(crate) use try_box_from_ptr;
621+
624622
macro_rules! try_slice {
625623
( $ptr:expr, $count:expr ) => {
626624
if $ptr.is_null() {
@@ -631,20 +629,8 @@ macro_rules! try_slice {
631629
};
632630
}
633631

634-
#[doc(hidden)]
635-
#[macro_export]
636-
macro_rules! try_mut_slice {
637-
( $ptr:expr, $count:expr ) => {
638-
if $ptr.is_null() {
639-
return $crate::panic::NullParameterOrDefault::value();
640-
} else {
641-
unsafe { slice::from_raw_parts_mut($ptr, $count as usize) }
642-
}
643-
};
644-
}
632+
pub(crate) use try_slice;
645633

646-
#[doc(hidden)]
647-
#[macro_export]
648634
macro_rules! try_callback {
649635
( $var:ident ) => {
650636
match $var {
@@ -653,6 +639,9 @@ macro_rules! try_callback {
653639
}
654640
};
655641
}
642+
643+
pub(crate) use try_callback;
644+
656645
/// Returns a static string containing the rustls-ffi version as well as the
657646
/// rustls version. The string is alive for the lifetime of the program and does
658647
/// not need to be freed.

0 commit comments

Comments
 (0)