Skip to content

Commit

Permalink
Ran cargo fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Mircea <mirceapetrebogdan@gmail.com>
  • Loading branch information
bobozaur committed Sep 26, 2023
1 parent 20f466b commit 3718fb1
Show file tree
Hide file tree
Showing 84 changed files with 891 additions and 764 deletions.
3 changes: 1 addition & 2 deletions did_doc/src/schema/did_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ use did_parser::{Did, DidUrl};
use serde::{Deserialize, Serialize};
use serde_json::Value;

use crate::error::DidDocumentBuilderError;

use super::{
service::Service,
types::uri::Uri,
utils::OneOrList,
verification_method::{VerificationMethod, VerificationMethodKind},
};
use crate::error::DidDocumentBuilderError;

pub type ControllerAlias = OneOrList<Did>;

Expand Down
3 changes: 1 addition & 2 deletions did_doc/src/schema/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ use std::collections::HashSet;

use serde::{Deserialize, Serialize};

use crate::error::DidDocumentBuilderError;

use super::{
types::{uri::Uri, url::Url},
utils::OneOrList,
};
use crate::error::DidDocumentBuilderError;

pub type ServiceTypeAlias = OneOrList<String>;

Expand Down
14 changes: 7 additions & 7 deletions did_doc/src/schema/verification_method/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@ mod public_key;
mod verification_method_kind;
mod verification_method_type;

pub use self::public_key::PublicKeyField;

use ::public_key::Key;
pub use verification_method_kind::VerificationMethodKind;
pub use verification_method_type::VerificationMethodType;

use did_parser::{Did, DidUrl};
use serde::{Deserialize, Serialize};
pub use verification_method_kind::VerificationMethodKind;
pub use verification_method_type::VerificationMethodType;

pub use self::public_key::PublicKeyField;
use crate::{error::DidDocumentBuilderError, schema::types::jsonwebkey::JsonWebKey};

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
Expand Down Expand Up @@ -160,16 +158,18 @@ impl CompleteVerificationMethodBuilder {
id: self.id,
controller: self.controller,
verification_method_type: self.verification_method_type,
public_key: self.public_key.unwrap(), // SAFETY: The builder will always set the public key
public_key: self.public_key.unwrap(), /* SAFETY: The builder will always set the
* public key */
}
}
}

#[cfg(test)]
mod tests {
use super::*;
use serde_json::Value;

use super::*;

fn create_valid_did() -> Did {
Did::parse("did:example:123456789abcdefghi".to_string()).unwrap()
}
Expand Down
11 changes: 6 additions & 5 deletions did_parser/src/did.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use std::convert::TryFrom;
use std::fmt::{Display, Formatter};
use std::str::FromStr;
use std::{
convert::TryFrom,
fmt::{Display, Formatter},
str::FromStr,
};

use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::DidUrl;
use crate::{error::ParseError, utils::parse::parse_did_method_id, DidRange};
use crate::{error::ParseError, utils::parse::parse_did_method_id, DidRange, DidUrl};

#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Did {
Expand Down
3 changes: 1 addition & 2 deletions did_parser/src/utils/parse.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::error::ParseError;
use crate::DidRange;
use crate::{error::ParseError, DidRange};

pub(crate) fn parse_key_value(
did_url: &str,
Expand Down
3 changes: 2 additions & 1 deletion did_parser/tests/did_url/positive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use did_parser::DidUrl;
use std::collections::HashMap;

use did_parser::DidUrl;

macro_rules! test_cases_positive {
($($name:ident: $input:expr, $expected_did:expr, $expected_method:expr, $expected_id:expr, $expected_path:expr, $expected_fragment:expr, $expected_queries:expr, $expected_params:expr)*) => {
$(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::shared_types::did_document_metadata::DidDocumentMetadata;
use std::io::Read;

use super::dereferencing_metadata::DidDereferencingMetadata;
use crate::shared_types::did_document_metadata::DidDocumentMetadata;

pub struct DidDereferencingOutput<R: Read + Send + Sync> {
dereferencing_metadata: DidDereferencingMetadata,
Expand Down
2 changes: 1 addition & 1 deletion did_resolver/src/traits/dereferenceable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ pub mod dereferencing_output;

use std::io::Read;

use crate::{error::GenericError, traits::resolvable::DidResolvable};
use async_trait::async_trait;
use did_parser::DidUrl;

use self::{
dereferencing_options::DidDereferencingOptions, dereferencing_output::DidDereferencingOutput,
};
use crate::{error::GenericError, traits::resolvable::DidResolvable};

#[async_trait]
pub trait DidDereferenceable: DidResolvable {
Expand Down
2 changes: 1 addition & 1 deletion did_resolver/src/traits/resolvable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ pub mod resolution_metadata;
pub mod resolution_options;
pub mod resolution_output;

use crate::error::GenericError;
use async_trait::async_trait;
use did_parser::Did;

use self::{resolution_options::DidResolutionOptions, resolution_output::DidResolutionOutput};
use crate::error::GenericError;

#[async_trait]
pub trait DidResolvable {
Expand Down
6 changes: 4 additions & 2 deletions did_resolver_registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ impl ResolverRegistry {

#[cfg(test)]
mod tests {
use super::*;
use std::{error::Error, pin::Pin};

use async_trait::async_trait;
use did_resolver::did_doc::schema::did_doc::DidDocumentBuilder;
use mockall::{automock, predicate::eq};
use std::{error::Error, pin::Pin};

use super::*;

struct DummyDidResolver;

Expand Down
3 changes: 1 addition & 2 deletions did_resolver_sov/src/dereferencing/dereferencer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use did_resolver::{
},
};

use crate::resolution::DidSovResolver;

use super::utils::dereference_did_document;
use crate::resolution::DidSovResolver;

#[async_trait]
impl DidDereferenceable for DidSovResolver {
Expand Down
15 changes: 9 additions & 6 deletions did_resolver_sov/src/dereferencing/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,17 @@ pub(crate) fn dereference_did_document<E: Default + Serialize>(

#[cfg(test)]
mod tests {
use super::*;

use did_resolver::did_doc::schema::did_doc::DidDocumentBuilder;
use did_resolver::did_doc::schema::verification_method::VerificationMethodType;
use did_resolver::did_parser::DidUrl;
use did_resolver::traits::resolvable::resolution_output::DidResolutionOutput;
use did_resolver::{
did_doc::schema::{
did_doc::DidDocumentBuilder, verification_method::VerificationMethodType,
},
did_parser::DidUrl,
traits::resolvable::resolution_output::DidResolutionOutput,
};
use serde_json::Value;

use super::*;

fn example_did_document_builder() -> DidDocumentBuilder<()> {
let verification_method = VerificationMethod::builder(
DidUrl::parse("did:example:123456789abcdefghi#keys-1".to_string()).unwrap(),
Expand Down
3 changes: 1 addition & 2 deletions did_resolver_sov/src/resolution/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@ use did_resolver::{
};
use serde_json::Value;

use super::utils::{is_valid_sovrin_did_id, ledger_response_to_ddo};
use crate::{
error::{parsing::ParsingErrorSource, DidSovError},
reader::AttrReader,
};

use super::utils::{is_valid_sovrin_did_id, ledger_response_to_ddo};

pub struct DidSovResolver {
ledger: Arc<dyn AttrReader>,
}
Expand Down
3 changes: 2 additions & 1 deletion did_resolver_sov/src/resolution/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,11 @@ pub(super) async fn ledger_response_to_ddo<E: Default>(

#[cfg(test)]
mod tests {
use super::*;
use chrono::TimeZone;
use did_resolver::did_doc::schema::verification_method::PublicKeyField;

use super::*;

#[test]
fn test_prepare_ids() {
let did = "did:example:1234567890".to_string();
Expand Down
9 changes: 5 additions & 4 deletions did_resolver_sov/src/service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::HashSet;
use std::fmt::Display;
use std::{collections::HashSet, fmt::Display};

use serde::{Deserialize, Deserializer};
use url::Url;
Expand Down Expand Up @@ -66,10 +65,12 @@ where

#[cfg(test)]
mod tests {
use super::*;
use serde_json::from_str;
use std::iter::FromIterator;

use serde_json::from_str;

use super::*;

#[test]
fn test_deserialize_endpoint_did_sov() {
let json = r#"{
Expand Down
15 changes: 7 additions & 8 deletions did_resolver_sov/tests/resolution.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::{sync::Arc, thread, time::Duration};

use aries_vcx::core::profile::profile::Profile;
use aries_vcx::{
common::ledger::{
service_didsov::{DidSovServiceType, EndpointDidSov},
transactions::write_endpoint,
},
core::profile::profile::Profile,
utils::devsetup::SetupProfile,
};
use did_resolver::did_parser::Did;
use did_resolver::traits::resolvable::{resolution_options::DidResolutionOptions, DidResolvable};
use did_resolver_sov::reader::ConcreteAttrReader;
use did_resolver_sov::resolution::DidSovResolver;
use did_resolver::{
did_parser::Did,
traits::resolvable::{resolution_options::DidResolutionOptions, DidResolvable},
};
use did_resolver_sov::{reader::ConcreteAttrReader, resolution::DidSovResolver};

async fn write_test_endpoint(profile: &Arc<dyn Profile>, did: &str) {
let endpoint = EndpointDidSov::create()
Expand Down
3 changes: 2 additions & 1 deletion libvdrtools/indy-api-types/src/domain/wallet/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use serde_json::value::Value;
use std::collections::HashMap;

use serde_json::value::Value;

use crate::validation::Validatable;

#[derive(Debug, Serialize, Deserialize, Clone, Default)]
Expand Down
14 changes: 5 additions & 9 deletions libvdrtools/indy-api-types/src/errors.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
use std::{
cell,
cell::RefCell,
error::Error,
ffi::{CString, NulError},
fmt, io, ptr,
sync::Arc,
};

use libc::c_char;
use log;
use std::error::Error;
use thiserror::Error as ThisError;

#[cfg(feature = "casting_errors_wallet")]
use sqlx;

use thiserror::Error as ThisError;
#[cfg(feature = "casting_errors_misc")]
use ursa::errors::{UrsaCryptoError, UrsaCryptoErrorKind};

use libc::c_char;

use crate::ErrorCode;

pub mod prelude {
Expand Down Expand Up @@ -616,8 +613,8 @@ pub fn set_current_error(err: &IndyError) {
/// 1) synchronous - in the same application thread
/// 2) asynchronous - inside of function callback
///
/// NOTE: Error is stored until the next one occurs in the same execution thread or until asynchronous callback finished.
/// Returning pointer has the same lifetime.
/// NOTE: Error is stored until the next one occurs in the same execution thread or until
/// asynchronous callback finished. Returning pointer has the same lifetime.
///
/// #Params
/// * `error_json_p` - Reference that will contain error details (if any error has occurred before)
Expand All @@ -629,7 +626,6 @@ pub fn set_current_error(err: &IndyError) {
/// 2) calling `indy_set_runtime_config` API function with `collect_backtrace: true`
/// "message": str - human-readable error description
/// }
///
pub fn get_current_error_c_json() -> *const c_char {
let mut value = ptr::null();

Expand Down
7 changes: 4 additions & 3 deletions libvdrtools/indy-api-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ pub enum ErrorCode {
// Invalid library state was detected in runtime. It signals library bug
CommonInvalidState = 112,

// Object (json, config, key, credential and etc...) passed by library caller has invalid structure
// Object (json, config, key, credential and etc...) passed by library caller has invalid
// structure
CommonInvalidStructure = 113,

// IO Error
Expand Down Expand Up @@ -211,8 +212,8 @@ pub enum ErrorCode {
// Timeout for action
PoolLedgerTimeout = 307,

// Attempt to open Pool for witch Genesis Transactions are not compatible with set Protocol version.
// Call pool.indy_set_protocol_version to set correct Protocol version.
// Attempt to open Pool for witch Genesis Transactions are not compatible with set Protocol
// version. Call pool.indy_set_protocol_version to set correct Protocol version.
PoolIncompatibleProtocolVersion = 308,

// Item not found on ledger.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
extern crate sodiumoxide;

use self::sodiumoxide::{crypto::aead::chacha20poly1305_ietf, utils};
use super::pwhash_argon2i13;
use indy_api_types::{domain::wallet::KeyDerivationMethod, errors::prelude::*};
use std::{
cmp, io,
io::{Read, Write},
};

use indy_api_types::{domain::wallet::KeyDerivationMethod, errors::prelude::*};

use self::sodiumoxide::{crypto::aead::chacha20poly1305_ietf, utils};
use super::pwhash_argon2i13;

pub const KEYBYTES: usize = chacha20poly1305_ietf::KEYBYTES;
pub const NONCEBYTES: usize = chacha20poly1305_ietf::NONCEBYTES;
pub const TAGBYTES: usize = chacha20poly1305_ietf::TAGBYTES;
Expand Down Expand Up @@ -303,8 +305,8 @@ mod tests {
pub fn gen_nonce_and_encrypt_detached_decrypt_detached_works() {
let data = randombytes(100);
let key = gen_key();
// AAD allows the sender to tie extra (protocol) data to the encryption. Example JWE enc and alg
// Which the receiver MUST then check before decryption
// AAD allows the sender to tie extra (protocol) data to the encryption. Example JWE enc and
// alg Which the receiver MUST then check before decryption
let aad = b"some protocol data input to the encryption";

let (c, nonce, tag) = gen_nonce_and_encrypt_detached(&data, aad, &key);
Expand Down
3 changes: 2 additions & 1 deletion libvdrtools/indy-utils/src/crypto/ed25519_box/sodium.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
extern crate sodiumoxide;

use self::sodiumoxide::crypto::box_;
use indy_api_types::errors::prelude::*;

use self::sodiumoxide::crypto::box_;

pub const NONCEBYTES: usize = box_::curve25519xsalsa20poly1305::NONCEBYTES;
pub const PUBLICKEYBYTES: usize = box_::curve25519xsalsa20poly1305::PUBLICKEYBYTES;
pub const SECRETKEYBYTES: usize = box_::curve25519xsalsa20poly1305::SECRETKEYBYTES;
Expand Down
1 change: 0 additions & 1 deletion libvdrtools/indy-utils/src/crypto/ed25519_sign/sodium.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use indy_api_types::errors::prelude::*;

use libc::c_int;
use sodiumoxide::crypto::{box_, sign};

Expand Down
Loading

0 comments on commit 3718fb1

Please sign in to comment.