Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
kornelski committed May 12, 2023
1 parent 4be5ee1 commit 816c796
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions security-framework/src/authorization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl AuthorizationItem {
///
/// If `name` isn't convertable to a `CString` it will return
/// Err(errSecConversionError).
pub fn name(&self) -> &str {
#[must_use] pub fn name(&self) -> &str {
unsafe {
CStr::from_ptr(self.0.name)
.to_str()
Expand All @@ -96,7 +96,7 @@ impl AuthorizationItem {
/// The information pertaining to the name field. Do not rely on NULL
/// termination of string data.
#[inline]
pub fn value(&self) -> Option<&[u8]> {
#[must_use] pub fn value(&self) -> Option<&[u8]> {
if self.0.value.is_null() {
return None;
}
Expand Down
4 changes: 2 additions & 2 deletions security-framework/src/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use core_foundation::error::{CFError, CFErrorRef};
use core_foundation::number::CFNumber;
#[cfg(feature = "serial-number-bigint")]
use num_bigint::BigUint;
use security_framework_sys::item::*;
use security_framework_sys::item::kSecValueRef;
#[cfg(any(feature = "OSX_10_12", target_os = "ios"))]
use std::ops::Deref;

Expand Down Expand Up @@ -187,7 +187,7 @@ impl SecCertificate {
trust.copy_public_key()
}

/// Translates to SecItemDelete, passing in the SecCertificateRef
/// Translates to `SecItemDelete`, passing in the `SecCertificateRef`
pub fn delete(&self) -> Result<(), Error> {
let query = CFMutableDictionary::from_CFType_pairs(&[(
unsafe { kSecValueRef }.to_void(),
Expand Down
4 changes: 2 additions & 2 deletions security-framework/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use core_foundation::base::TCFType;
use core_foundation::base::ToVoid;
use core_foundation::dictionary::CFMutableDictionary;
use security_framework_sys::base::SecIdentityRef;
use security_framework_sys::identity::*;
use security_framework_sys::identity::{SecIdentityCopyCertificate, SecIdentityCopyPrivateKey, SecIdentityGetTypeID};
use security_framework_sys::item::kSecValueRef;
use security_framework_sys::keychain_item::SecItemDelete;
use std::fmt;
Expand Down Expand Up @@ -60,7 +60,7 @@ impl SecIdentity {
}
}

/// Translates to SecItemDelete, passing in the SecIdentityRef
/// Translates to `SecItemDelete`, passing in the `SecIdentityRef`
pub fn delete(&self) -> Result<(), Error> {
let query = CFMutableDictionary::from_CFType_pairs(&[(
unsafe { kSecValueRef }.to_void(),
Expand Down
32 changes: 16 additions & 16 deletions security-framework/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,25 @@ impl ItemClass {
pub struct KeyClass(CFStringRef);

impl KeyClass {
/// kSecAttrKeyClassPublic
/// `kSecAttrKeyClassPublic`
#[inline(always)]
pub fn public() -> Self {
#[must_use] pub fn public() -> Self {
unsafe { Self(kSecAttrKeyClassPublic) }
}
/// kSecAttrKeyClassPrivate
/// `kSecAttrKeyClassPrivate`
#[inline(always)]
pub fn private() -> Self {
#[must_use] pub fn private() -> Self {
unsafe { Self(kSecAttrKeyClassPrivate) }
}
/// kSecAttrKeyClassSymmetric
/// `kSecAttrKeyClassSymmetric`
#[inline(always)]
pub fn symmetric() -> Self {
#[must_use] pub fn symmetric() -> Self {
unsafe { Self(kSecAttrKeyClassSymmetric) }
}

#[inline]
fn to_value(self) -> CFType {
unsafe { CFType::wrap_under_get_rule(self.0 as *const _) }
unsafe { CFType::wrap_under_get_rule(self.0.cast()) }
}
}

Expand Down Expand Up @@ -241,8 +241,8 @@ impl ItemSearchOptions {

/// Search for a certificate with the given public key hash.
///
/// This is only compatible with [ItemClass::certificate], to search for
/// a key by public key hash use [ItemSearchOptions::application_label]
/// This is only compatible with [`ItemClass::certificate`], to search for
/// a key by public key hash use [`ItemSearchOptions::application_label`]
/// instead.
#[inline(always)]
pub fn pub_key_hash(&mut self, pub_key_hash: &[u8]) -> &mut Self {
Expand All @@ -252,8 +252,8 @@ impl ItemSearchOptions {

/// Search for a key with the given public key hash.
///
/// This is only compatible with [ItemClass::key], to search for a
/// certificate by the public key hash use [ItemSearchOptions::pub_key_hash]
/// This is only compatible with [`ItemClass::key`], to search for a
/// certificate by the public key hash use [`ItemSearchOptions::pub_key_hash`]
/// instead.
#[inline(always)]
pub fn application_label(&mut self, app_label: &[u8]) -> &mut Self {
Expand Down Expand Up @@ -517,7 +517,7 @@ impl SearchResult {
/// wrapper).
///
/// When finished populating options, call `to_dictionary()` and pass the
/// resulting CFDictionary to `add_item`.
/// resulting `CFDictionary` to `add_item`.
pub struct ItemAddOptions {
/// The value (by ref or data) of the item to add, required.
pub value: ItemAddValue,
Expand All @@ -529,10 +529,10 @@ pub struct ItemAddOptions {

impl ItemAddOptions {
/// Specifies the item to add.
pub fn new(value: ItemAddValue) -> Self {
#[must_use] pub fn new(value: ItemAddValue) -> Self {
Self{ value, label: None, location: None }
}
/// Specifies the kSecAttrLabel attribute.
/// Specifies the `kSecAttrLabel` attribute.
pub fn set_label(&mut self, label: impl Into<String>) -> &mut Self {
self.label = Some(label.into());
self
Expand All @@ -542,7 +542,7 @@ impl ItemAddOptions {
self.location = Some(location);
self
}
/// Populates a CFDictionary to be passed to
/// Populates a `CFDictionary` to be passed to
pub fn to_dictionary(&self) -> CFDictionary {
let mut dict = CFMutableDictionary::from_CFType_pairs(&[]);

Expand Down Expand Up @@ -652,7 +652,7 @@ pub enum Location {
FileKeychain(crate::os::macos::keychain::SecKeychain),
}

/// Translates to SecItemAdd. Use `ItemAddOptions` to build an `add_params`
/// Translates to `SecItemAdd`. Use `ItemAddOptions` to build an `add_params`
/// `CFDictionary`.
pub fn add_item(add_params: CFDictionary) -> Result<()> {
cvt(unsafe { SecItemAdd(add_params.as_concrete_TypeRef(), std::ptr::null_mut()) })
Expand Down
4 changes: 2 additions & 2 deletions security-framework/src/os/macos/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ pub struct CertificateProperties(CFDictionary);

impl CertificateProperties {
/// Retrieves a specific property identified by its OID.
pub fn get(&self, oid: CertificateOid) -> Option<CertificateProperty> {
#[must_use] pub fn get(&self, oid: CertificateOid) -> Option<CertificateProperty> {
unsafe {
self.0.find(oid.as_ptr() as *const c_void).map(|value| {
self.0.find(oid.as_ptr().cast::<c_void>()).map(|value| {
CertificateProperty(CFDictionary::wrap_under_get_rule(*value as *mut _))
})
}
Expand Down
2 changes: 1 addition & 1 deletion security-framework/src/os/macos/identity.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! OSX specific extensions to identity functionality.
use core_foundation::array::CFArray;
use core_foundation::base::TCFType;
use security_framework_sys::identity::*;
use security_framework_sys::identity::SecIdentityCreateWithCertificate;
use std::ptr;

use crate::base::Result;
Expand Down
2 changes: 1 addition & 1 deletion security-framework/src/os/macos/keychain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl CreateOptions {
let path_name = CString::new(path_name).unwrap();

let (password, password_len) = match self.password {
Some(ref password) => (password.as_ptr() as *const c_void, password.len() as u32),
Some(ref password) => (password.as_ptr().cast::<c_void>(), password.len() as u32),
None => (ptr::null(), 0),
};

Expand Down
6 changes: 3 additions & 3 deletions security-framework/src/passwords_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use security_framework_sys::item::{
};
use crate::access_control::SecAccessControl;

/// PasswordOptions constructor
/// `PasswordOptions` constructor
pub struct PasswordOptions {
/// query built for the keychain request
pub query: Vec<(CFString, CFType)>,
Expand Down Expand Up @@ -43,7 +43,7 @@ impl PasswordOptions {
/// Create a new generic password options
/// Generic passwords are identified by service and account. They have other
/// attributes, but this interface doesn't allow specifying them.
pub fn new_generic_password(service: &str, account: &str) -> Self {
#[must_use] pub fn new_generic_password(service: &str, account: &str) -> Self {
let query = vec![
(
unsafe { CFString::wrap_under_get_rule(kSecClass) },
Expand All @@ -64,7 +64,7 @@ impl PasswordOptions {
/// Create a new internet password options
/// Internet passwords are identified by a number of attributes.
/// They can have others, but this interface doesn't allow specifying them.
pub fn new_internet_password(
#[must_use] pub fn new_internet_password(
server: &str,
security_domain: Option<&str>,
account: &str,
Expand Down
2 changes: 1 addition & 1 deletion security-framework/src/random.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Randomness support.
use security_framework_sys::random::*;
use security_framework_sys::random::{SecRandomCopyBytes, SecRandomRef, kSecRandomDefault};
use std::io;

/// A source of random data.
Expand Down

0 comments on commit 816c796

Please sign in to comment.