diff --git a/src/lib.rs b/src/lib.rs index eb24b06..86b694f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,6 +20,10 @@ pub use julid::Julid; /// This `unsafe extern "C"` function is the main entry point into the loadable /// SQLite extension. By default, it and the `plugin` module it depends on will /// not be built. Build with `cargo build --features plugin` +/// +/// # Safety +/// This is FFI; it's inherently unsafe. But this function is called by +/// sqlite, not by a user, so it should be OK. #[cfg(feature = "plugin")] #[no_mangle] pub unsafe extern "C" fn sqlite3_julid_init( @@ -40,7 +44,7 @@ pub unsafe extern "C" fn sqlite3_julid_init( pub mod sqlite_plugin { use sqlite_loadable::{ api, define_scalar_function, - prelude::{sqlite3, sqlite3_context, sqlite3_value, FunctionFlags}, + prelude::{sqlite3_context, sqlite3_value, FunctionFlags}, Result, }; @@ -92,7 +96,7 @@ pub mod sqlite_plugin { /// 01HJSHZ0PN000EKP3H94R6TPWH /// ``` pub fn julid_string(context: *mut sqlite3_context, id: &[*mut sqlite3_value]) -> Result<()> { - if let Some(value) = id.get(0) { + if let Some(value) = id.first() { let id = api::value_blob(value); let bytes: [u8; 16] = id.try_into().map_err(|_| { sqlite_loadable::Error::new_message("Could not convert given value to Julid") @@ -116,7 +120,7 @@ pub mod sqlite_plugin { /// 2023-07-27 17:47:50 /// ``` pub fn julid_seconds(context: *mut sqlite3_context, id: &[*mut sqlite3_value]) -> Result<()> { - if let Some(value) = id.get(0) { + if let Some(value) = id.first() { let id = api::value_blob(value); let bytes: [u8; 16] = id.try_into().map_err(|_| { sqlite_loadable::Error::new_message("Could not convert given value to Julid") @@ -143,7 +147,7 @@ pub mod sqlite_plugin { /// 0 /// ``` pub fn julid_counter(context: *mut sqlite3_context, id: &[*mut sqlite3_value]) -> Result<()> { - if let Some(value) = id.get(0) { + if let Some(value) = id.first() { let id = api::value_blob(value); let bytes: [u8; 16] = id.try_into().map_err(|_| { sqlite_loadable::Error::new_message("Could not convert given value to Julid") @@ -167,7 +171,7 @@ pub mod sqlite_plugin { /// 110787724287475712 /// ``` pub fn julid_sortable(context: *mut sqlite3_context, id: &[*mut sqlite3_value]) -> Result<()> { - if let Some(value) = id.get(0) { + if let Some(value) = id.first() { let id = api::value_blob(value); let bytes: [u8; 16] = id.try_into().map_err(|_| { sqlite_loadable::Error::new_message("Could not convert given value to Julid")