Skip to content

Commit 4cdd948

Browse files
authored
Merge pull request #333 from wprzytula/expose-public-rust-api
Expose public rust API & enable API lints
2 parents c622d61 + f7c56c0 commit 4cdd948

19 files changed

+1091
-100
lines changed

scylla-rust-wrapper/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ strip = "none"
6060

6161
[lints.rust]
6262
unsafe-op-in-unsafe-fn = "warn"
63+
unnameable_types = "warn"
64+
unreachable_pub = "warn"
6365
unexpected_cfgs = { level = "warn", check-cfg = [
6466
'cfg(cpp_integration_testing)',
6567
] }

scylla-rust-wrapper/src/api.rs

Lines changed: 925 additions & 0 deletions
Large diffs are not rendered by default.

scylla-rust-wrapper/src/argconv.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ macro_rules! make_c_str {
7676
pub(crate) use make_c_str;
7777

7878
mod sealed {
79+
// This is a sealed trait - its whole purpose is to be unnameable.
80+
// This means we need to disable the check.
81+
#[expect(unnameable_types)]
7982
pub trait Sealed {}
8083
}
8184

@@ -330,8 +333,19 @@ impl<T: Sized> CassPtr<'_, T, (Exclusive, CMut)> {
330333
}
331334

332335
mod origin_sealed {
336+
// This is a sealed trait - its whole purpose is to be unnameable.
337+
// This means we need to disable the check.
338+
#[expect(unnameable_types)]
333339
pub trait FromBoxSealed {}
340+
341+
// This is a sealed trait - its whole purpose is to be unnameable.
342+
// This means we need to disable the check.
343+
#[expect(unnameable_types)]
334344
pub trait FromArcSealed {}
345+
346+
// This is a sealed trait - its whole purpose is to be unnameable.
347+
// This means we need to disable the check.
348+
#[expect(unnameable_types)]
335349
pub trait FromRefSealed {}
336350
}
337351

@@ -414,7 +428,7 @@ pub trait BoxFFI: Sized + origin_sealed::FromBoxSealed {
414428
/// The data should be allocated via [`Arc::new`], and then returned to the user as a pointer.
415429
/// The user is responsible for freeing the memory associated
416430
/// with the pointer using corresponding driver's API function.
417-
pub(crate) trait ArcFFI: Sized + origin_sealed::FromArcSealed {
431+
pub trait ArcFFI: Sized + origin_sealed::FromArcSealed {
418432
/// Creates a pointer from a valid reference to Arc-allocated data.
419433
/// Holder of the pointer borrows the pointee.
420434
#[allow(clippy::needless_lifetimes)]

scylla-rust-wrapper/src/batch.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use crate::argconv::{
33
FFI, FromBox,
44
};
55
use crate::cass_error::CassError;
6-
use crate::cass_types::{CassBatchType, CassConsistency, make_batch_type};
6+
pub use crate::cass_types::CassBatchType;
7+
use crate::cass_types::{CassConsistency, make_batch_type};
78
use crate::config_value::MaybeUnsetConfig;
89
use crate::exec_profile::PerStatementExecProfile;
910
use crate::retry_policy::CassRetryPolicy;

scylla-rust-wrapper/src/cass_error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use scylla::errors::*;
22

33
// Re-export error types.
4-
pub(crate) use crate::cass_error_types::{CassError, CassErrorSource};
4+
pub use crate::cass_error_types::{CassError, CassErrorSource};
55
use crate::execution_error::CassErrorResult;
66
use crate::statement::UnknownNamedParameterError;
77

scylla-rust-wrapper/src/cass_types.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use std::cell::UnsafeCell;
88
use std::os::raw::c_char;
99
use std::sync::Arc;
1010

11-
pub(crate) use crate::cass_batch_types::CassBatchType;
12-
pub(crate) use crate::cass_consistency_types::CassConsistency;
13-
pub(crate) use crate::cass_data_types::CassValueType;
11+
pub use crate::cass_batch_types::CassBatchType;
12+
pub use crate::cass_consistency_types::CassConsistency;
13+
pub use crate::cass_data_types::CassValueType;
1414

1515
#[derive(Clone, Debug)]
1616
#[cfg_attr(test, derive(PartialEq, Eq))]

scylla-rust-wrapper/src/collection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pub unsafe extern "C" fn cass_collection_new(
154154
}
155155

156156
#[unsafe(no_mangle)]
157-
unsafe extern "C" fn cass_collection_new_from_data_type(
157+
pub unsafe extern "C" fn cass_collection_new_from_data_type(
158158
data_type: CassBorrowedSharedPtr<CassDataType, CConst>,
159159
item_count: size_t,
160160
) -> CassOwnedExclusivePtr<CassCollection, CMut> {
@@ -185,7 +185,7 @@ unsafe extern "C" fn cass_collection_new_from_data_type(
185185
}
186186

187187
#[unsafe(no_mangle)]
188-
unsafe extern "C" fn cass_collection_data_type(
188+
pub unsafe extern "C" fn cass_collection_data_type(
189189
collection: CassBorrowedSharedPtr<CassCollection, CConst>,
190190
) -> CassBorrowedSharedPtr<CassDataType, CConst> {
191191
let Some(collection_ref) = BoxFFI::as_ref(collection) else {

scylla-rust-wrapper/src/execution_error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::argconv::*;
22
use crate::cass_error::*;
3+
pub use crate::cass_error::{CassError, CassErrorSource};
34
use crate::cass_error_types::CassWriteType;
45
use crate::cass_types::CassConsistency;
56
use crate::types::*;

scylla-rust-wrapper/src/future.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use tokio::task::JoinHandle;
1717
use tokio::time::Duration;
1818

1919
#[derive(Debug)]
20-
pub enum CassResultValue {
20+
pub(crate) enum CassResultValue {
2121
Empty,
2222
QueryResult(Arc<CassResult>),
2323
QueryError(Arc<CassErrorResult>),
@@ -26,7 +26,7 @@ pub enum CassResultValue {
2626

2727
type CassFutureError = (CassError, String);
2828

29-
pub type CassFutureResult = Result<CassResultValue, CassFutureError>;
29+
pub(crate) type CassFutureResult = Result<CassResultValue, CassFutureError>;
3030

3131
pub type CassFutureCallback = Option<
3232
unsafe extern "C" fn(future: CassBorrowedSharedPtr<CassFuture, CMut>, data: *mut c_void),

scylla-rust-wrapper/src/inet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ use std::os::raw::c_char;
99
use std::slice::from_raw_parts;
1010
use std::str::FromStr;
1111

12-
pub(crate) use crate::cass_inet_types::CassInet;
12+
pub use crate::cass_inet_types::CassInet;
1313

1414
#[repr(u8)] // address_length field in CassInet is cass_uint8_t
1515
#[allow(non_camel_case_types)]
1616
#[derive(Debug, Copy, Clone)]
17-
pub enum CassInetLength {
17+
pub(crate) enum CassInetLength {
1818
CASS_INET_V4 = 4,
1919
CASS_INET_V6 = 16,
2020
}

0 commit comments

Comments
 (0)