Cleanup: move ?Sized bounds to "where".

This commit is contained in:
Heiko Schaefer 2022-02-18 15:06:50 +01:00
parent 265587252a
commit 282b16fdba
No known key found for this signature in database
GPG key ID: 4A849A1904CCBD7D
2 changed files with 12 additions and 12 deletions

View file

@ -22,13 +22,13 @@ const MAX_BUFFER_SIZE: usize = 264;
/// ///
/// If the reply is truncated, this fn assembles all the parts and returns /// If the reply is truncated, this fn assembles all the parts and returns
/// them as one aggregated Response. /// them as one aggregated Response.
pub(crate) fn send_command<C: ?Sized>( pub(crate) fn send_command<C>(
card_tx: &mut C, card_tx: &mut C,
cmd: Command, cmd: Command,
expect_reply: bool, expect_reply: bool,
) -> Result<RawResponse, Error> ) -> Result<RawResponse, Error>
where where
C: CardTransaction, C: CardTransaction + ?Sized,
{ {
let mut resp = RawResponse::try_from(send_command_low_level( let mut resp = RawResponse::try_from(send_command_low_level(
card_tx, card_tx,
@ -84,13 +84,13 @@ where
/// ///
/// If the response is chained, this fn only returns one chunk, the caller /// If the response is chained, this fn only returns one chunk, the caller
/// needs to re-assemble the chained response-parts. /// needs to re-assemble the chained response-parts.
fn send_command_low_level<C: ?Sized>( fn send_command_low_level<C>(
card_tx: &mut C, card_tx: &mut C,
cmd: Command, cmd: Command,
expect_response: Expect, expect_response: Expect,
) -> Result<Vec<u8>, Error> ) -> Result<Vec<u8>, Error>
where where
C: CardTransaction, C: CardTransaction + ?Sized,
{ {
let (ext_support, chaining_support, mut max_cmd_bytes, max_rsp_bytes) = let (ext_support, chaining_support, mut max_cmd_bytes, max_rsp_bytes) =
if let Some(caps) = card_tx.card_caps() { if let Some(caps) = card_tx.card_caps() {

View file

@ -29,7 +29,7 @@ use crate::{CardTransaction, Error};
/// ///
/// `fp_from_pub` calculates the fingerprint for a public key data object and /// `fp_from_pub` calculates the fingerprint for a public key data object and
/// creation timestamp /// creation timestamp
pub(crate) fn gen_key_with_metadata<C: ?Sized>( pub(crate) fn gen_key_with_metadata<C>(
card_tx: &mut C, card_tx: &mut C,
fp_from_pub: fn( fp_from_pub: fn(
&PublicKeyMaterial, &PublicKeyMaterial,
@ -40,7 +40,7 @@ pub(crate) fn gen_key_with_metadata<C: ?Sized>(
algo: Option<&Algo>, algo: Option<&Algo>,
) -> Result<(PublicKeyMaterial, KeyGenerationTime), Error> ) -> Result<(PublicKeyMaterial, KeyGenerationTime), Error>
where where
C: CardTransaction, C: CardTransaction + ?Sized,
{ {
// Set algo on card if it's Some // Set algo on card if it's Some
if let Some(target_algo) = algo { if let Some(target_algo) = algo {
@ -129,12 +129,12 @@ fn tlv_to_pubkey(tlv: &Tlv, algo: &Algo) -> Result<PublicKeyMaterial> {
/// ///
/// This runs the low level key generation primitive on the card. /// This runs the low level key generation primitive on the card.
/// (This does not set algorithm attributes, creation time or fingerprint) /// (This does not set algorithm attributes, creation time or fingerprint)
pub(crate) fn generate_asymmetric_key_pair<C: ?Sized>( pub(crate) fn generate_asymmetric_key_pair<C>(
card_tx: &mut C, card_tx: &mut C,
key_type: KeyType, key_type: KeyType,
) -> Result<Tlv, Error> ) -> Result<Tlv, Error>
where where
C: CardTransaction, C: CardTransaction + ?Sized,
{ {
// generate key // generate key
let crt = control_reference_template(key_type)?; let crt = control_reference_template(key_type)?;
@ -154,12 +154,12 @@ where
/// in the card or imported") /// in the card or imported")
/// ///
/// (See 7.2.14 GENERATE ASYMMETRIC KEY PAIR) /// (See 7.2.14 GENERATE ASYMMETRIC KEY PAIR)
pub(crate) fn public_key<C: ?Sized>( pub(crate) fn public_key<C>(
card_tx: &mut C, card_tx: &mut C,
key_type: KeyType, key_type: KeyType,
) -> Result<PublicKeyMaterial, Error> ) -> Result<PublicKeyMaterial, Error>
where where
C: CardTransaction, C: CardTransaction + ?Sized,
{ {
// get current algo // get current algo
let ard = card_tx.application_related_data()?; // FIXME: caching let ard = card_tx.application_related_data()?; // FIXME: caching
@ -183,14 +183,14 @@ where
/// If the key is suitable for `key_type`, an Error is returned (either /// If the key is suitable for `key_type`, an Error is returned (either
/// caused by checks before attempting to upload the key to the card, or by /// caused by checks before attempting to upload the key to the card, or by
/// an error that the card reports during an attempt to upload the key). /// an error that the card reports during an attempt to upload the key).
pub(crate) fn key_import<C: ?Sized>( pub(crate) fn key_import<C>(
card_tx: &mut C, card_tx: &mut C,
key: Box<dyn CardUploadableKey>, key: Box<dyn CardUploadableKey>,
key_type: KeyType, key_type: KeyType,
algo_info: Option<AlgoInfo>, algo_info: Option<AlgoInfo>,
) -> Result<(), Error> ) -> Result<(), Error>
where where
C: CardTransaction, C: CardTransaction + ?Sized,
{ {
// FIXME: caching? // FIXME: caching?
let ard = card_tx.application_related_data()?; let ard = card_tx.application_related_data()?;