Skip to content

Commit

Permalink
refactor .clone_into calls into .to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
wulfraem committed May 8, 2024
1 parent 00d786d commit 8fd7f88
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion identity_credential/src/validator/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) fn encode_public_ed25519_jwk(public_key: &PublicKey) -> Jwk {
let mut params = JwkParamsOkp::new();
params.x = x;
params.d = None;
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
let mut jwk = Jwk::from_params(params);
jwk.set_alg(JwsAlgorithm::EdDSA.name());
jwk
Expand Down
2 changes: 1 addition & 1 deletion identity_iota_core/src/document/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn encode_public_ed25519_jwk(public_key: &[u8]) -> Jwk {
let mut params = JwkParamsOkp::new();
params.x = x;
params.d = None;
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
let mut jwk = Jwk::from_params(params);
jwk.set_alg(JwsAlgorithm::EdDSA.name());
jwk
Expand Down
2 changes: 1 addition & 1 deletion identity_storage/src/key_storage/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ pub(crate) fn encode_jwk(private_key: &SecretKey, public_key: &crypto::signature
let mut params = JwkParamsOkp::new();
params.x = x;
params.d = Some(d);
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
Jwk::from_params(params)
}
8 changes: 4 additions & 4 deletions identity_storage/src/key_storage/memstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ mod tests {
let store: JwkMemStore = JwkMemStore::new();

let mut ec_params = JwkParamsEc::new();
EcCurve::P256.name().clone_into(&mut ec_params.crv);
"".clone_into(&mut ec_params.x);
"".clone_into(&mut ec_params.y);
ec_params.d = Some("".to_owned());
ec_params.crv = EcCurve::P256.name().to_string();
ec_params.x = String::new();
ec_params.y = String::new();
ec_params.d = Some(String::new());
let jwk_ec = Jwk::from_params(ec_params);

let err = store.insert(jwk_ec).await.unwrap_err();
Expand Down
8 changes: 4 additions & 4 deletions identity_storage/src/key_storage/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ pub(crate) async fn test_incompatible_key_alg(store: impl JwkStorage) {

pub(crate) async fn test_incompatible_key_type(store: impl JwkStorage) {
let mut ec_params = JwkParamsEc::new();
EcCurve::P256.name().clone_into(&mut ec_params.crv);
"".clone_into(&mut ec_params.x);
"".clone_into(&mut ec_params.y);
ec_params.d = Some("".to_owned());
ec_params.crv = EcCurve::P256.name().to_string();
ec_params.x = String::new();
ec_params.y = String::new();
ec_params.d = Some(String::new());
let jwk_ec = Jwk::from_params(ec_params);

let err = store.insert(jwk_ec).await.unwrap_err();
Expand Down
2 changes: 1 addition & 1 deletion identity_storage/src/storage/tests/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ pub(crate) fn encode_public_ed25519_jwk(public_key: &PublicKey) -> Jwk {
let mut params = JwkParamsOkp::new();
params.x = x;
params.d = None;
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
let mut jwk = Jwk::from_params(params);
jwk.set_alg(JwsAlgorithm::EdDSA.name());
jwk
Expand Down
2 changes: 1 addition & 1 deletion identity_stronghold/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ pub(crate) fn encode_jwk(private_key: &SecretKey, public_key: &crypto::signature
let mut params = JwkParamsOkp::new();
params.x = x;
params.d = Some(d);
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
Jwk::from_params(params)
}
4 changes: 2 additions & 2 deletions identity_stronghold/src/stronghold_jwk_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ impl StrongholdStorage {

let mut params = JwkParamsOkp::new();
params.x = jwu::encode_b64(public_key);
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
let mut jwk: Jwk = Jwk::from_params(params);
jwk.set_alg(JwsAlgorithm::EdDSA.name());
jwk.set_kid(jwk.thumbprint_sha256_b64());
Expand Down Expand Up @@ -148,7 +148,7 @@ impl JwkStorage for StrongholdStorage {

let mut params = JwkParamsOkp::new();
params.x = jwu::encode_b64(public_key);
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
let mut jwk: Jwk = Jwk::from_params(params);
jwk.set_alg(alg.name());
jwk.set_kid(jwk.thumbprint_sha256_b64());
Expand Down
8 changes: 4 additions & 4 deletions identity_stronghold/src/tests/test_jwk_storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ mod jwk_storage_tests {

pub(crate) async fn test_incompatible_key_type(store: impl JwkStorage) {
let mut ec_params = JwkParamsEc::new();
EcCurve::P256.name().clone_into(&mut ec_params.crv);
"".clone_into(&mut ec_params.x);
"".clone_into(&mut ec_params.y);
ec_params.d = Some("".to_owned());
ec_params.crv = EcCurve::P256.name().to_string();
ec_params.x = String::new();
ec_params.y = String::new);
ec_params.d = Some(String::new());
let jwk_ec = Jwk::from_params(ec_params);

let err = store.insert(jwk_ec).await.unwrap_err();
Expand Down
2 changes: 1 addition & 1 deletion identity_stronghold/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(crate) fn encode_public_ed25519_jwk(public_key: &PublicKey) -> Jwk {
let mut params = JwkParamsOkp::new();
params.x = x;
params.d = None;
EdCurve::Ed25519.name().clone_into(&mut params.crv);
params.crv = EdCurve::Ed25519.name().to_string();
let mut jwk = Jwk::from_params(params);
jwk.set_alg(JwsAlgorithm::EdDSA.name());
jwk
Expand Down

0 comments on commit 8fd7f88

Please sign in to comment.