diff --git a/messages/src/decorators/attachment.rs b/messages/src/decorators/attachment.rs index 8f867c0289..203a39ba32 100644 --- a/messages/src/decorators/attachment.rs +++ b/messages/src/decorators/attachment.rs @@ -1,7 +1,6 @@ use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use serde_json::Value; -use shared_vcx::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use url::Url; @@ -59,22 +58,6 @@ pub enum AttachmentType { Links(Vec), } -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] -#[serde(rename_all = "snake_case")] -pub struct AttachmentFormatSpecifier { - pub attach_id: String, - pub format: MaybeKnown, -} - -#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] -#[serde(rename_all = "snake_case")] -pub struct OptionalIdAttachmentFormatSpecifier { - #[builder(default)] - #[serde(skip_serializing_if = "Option::is_none")] - pub attach_id: Option, - pub format: MaybeKnown, -} - #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] diff --git a/messages/src/lib.rs b/messages/src/lib.rs index f19daadac4..46ea11b5f9 100644 --- a/messages/src/lib.rs +++ b/messages/src/lib.rs @@ -17,8 +17,8 @@ use derive_more::From; use misc::utils; use msg_fields::protocols::{ cred_issuance::{v1::CredentialIssuanceV1, v2::CredentialIssuanceV2, CredentialIssuance}, - present_proof::{v2::PresentProofV2, PresentProof}, pickup::Pickup, + present_proof::{v2::PresentProofV2, PresentProof}, }; use msg_types::{ cred_issuance::CredentialIssuanceType, present_proof::PresentProofType, diff --git a/messages/src/msg_fields/protocols/common/attachment_format_specifier.rs b/messages/src/msg_fields/protocols/common/attachment_format_specifier.rs new file mode 100644 index 0000000000..1bf91efc5d --- /dev/null +++ b/messages/src/msg_fields/protocols/common/attachment_format_specifier.rs @@ -0,0 +1,23 @@ +use serde::{Deserialize, Serialize}; +use shared_vcx::maybe_known::MaybeKnown; +use typed_builder::TypedBuilder; + +/// Specifies that a particular Attachment, with the id of `attach_id`, has the format of `format`. +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] +#[serde(rename_all = "snake_case")] +pub struct AttachmentFormatSpecifier { + pub attach_id: String, + pub format: MaybeKnown, +} + +/// If `attach_id` is not [None], this specifies that a particular Attachment, with the id of +/// `attach_id`, has the format of `format`. If `attach_id` is [None], this structure is used to +/// indicate that a particular attachment `format` is supported by the sender of the message. +#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] +#[serde(rename_all = "snake_case")] +pub struct OptionalIdAttachmentFormatSpecifier { + #[builder(default)] + #[serde(skip_serializing_if = "Option::is_none")] + pub attach_id: Option, + pub format: MaybeKnown, +} diff --git a/messages/src/msg_fields/protocols/common/mod.rs b/messages/src/msg_fields/protocols/common/mod.rs new file mode 100644 index 0000000000..72073c81b1 --- /dev/null +++ b/messages/src/msg_fields/protocols/common/mod.rs @@ -0,0 +1 @@ +pub mod attachment_format_specifier; diff --git a/messages/src/msg_fields/protocols/cred_issuance/v2/issue_credential.rs b/messages/src/msg_fields/protocols/cred_issuance/v2/issue_credential.rs index 03544a3af5..228e07b7c6 100644 --- a/messages/src/msg_fields/protocols/cred_issuance/v2/issue_credential.rs +++ b/messages/src/msg_fields/protocols/cred_issuance/v2/issue_credential.rs @@ -2,12 +2,8 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ - decorators::{ - attachment::{Attachment, AttachmentFormatSpecifier}, - please_ack::PleaseAck, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, please_ack::PleaseAck, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_fields/protocols/cred_issuance/v2/offer_credential.rs b/messages/src/msg_fields/protocols/cred_issuance/v2/offer_credential.rs index 0d0db70072..f5bb521c43 100644 --- a/messages/src/msg_fields/protocols/cred_issuance/v2/offer_credential.rs +++ b/messages/src/msg_fields/protocols/cred_issuance/v2/offer_credential.rs @@ -3,11 +3,8 @@ use typed_builder::TypedBuilder; use super::CredentialPreviewV2; use crate::{ - decorators::{ - attachment::{Attachment, AttachmentFormatSpecifier}, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_fields/protocols/cred_issuance/v2/propose_credential.rs b/messages/src/msg_fields/protocols/cred_issuance/v2/propose_credential.rs index ec8b32f43f..54864668e0 100644 --- a/messages/src/msg_fields/protocols/cred_issuance/v2/propose_credential.rs +++ b/messages/src/msg_fields/protocols/cred_issuance/v2/propose_credential.rs @@ -3,11 +3,8 @@ use typed_builder::TypedBuilder; use super::CredentialPreviewV2; use crate::{ - decorators::{ - attachment::{Attachment, AttachmentFormatSpecifier}, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_fields/protocols/cred_issuance/v2/request_credential.rs b/messages/src/msg_fields/protocols/cred_issuance/v2/request_credential.rs index 811ea24e3b..d4d590129c 100644 --- a/messages/src/msg_fields/protocols/cred_issuance/v2/request_credential.rs +++ b/messages/src/msg_fields/protocols/cred_issuance/v2/request_credential.rs @@ -2,11 +2,8 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ - decorators::{ - attachment::{Attachment, AttachmentFormatSpecifier}, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_fields/protocols/mod.rs b/messages/src/msg_fields/protocols/mod.rs index bae4e6a82c..ae5b4a78ad 100644 --- a/messages/src/msg_fields/protocols/mod.rs +++ b/messages/src/msg_fields/protocols/mod.rs @@ -1,4 +1,5 @@ pub mod basic_message; +pub mod common; pub mod connection; pub mod cred_issuance; pub mod discover_features; diff --git a/messages/src/msg_fields/protocols/present_proof/v2/present.rs b/messages/src/msg_fields/protocols/present_proof/v2/present.rs index 9c6c9b6087..4d1bb76d79 100644 --- a/messages/src/msg_fields/protocols/present_proof/v2/present.rs +++ b/messages/src/msg_fields/protocols/present_proof/v2/present.rs @@ -2,12 +2,8 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ - decorators::{ - attachment::{Attachment, AttachmentFormatSpecifier}, - please_ack::PleaseAck, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, please_ack::PleaseAck, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_fields/protocols/present_proof/v2/propose.rs b/messages/src/msg_fields/protocols/present_proof/v2/propose.rs index 98c83174f1..5342323489 100644 --- a/messages/src/msg_fields/protocols/present_proof/v2/propose.rs +++ b/messages/src/msg_fields/protocols/present_proof/v2/propose.rs @@ -2,11 +2,8 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ - decorators::{ - attachment::{Attachment, OptionalIdAttachmentFormatSpecifier}, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::OptionalIdAttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_fields/protocols/present_proof/v2/request.rs b/messages/src/msg_fields/protocols/present_proof/v2/request.rs index 9cf34870cb..c204dce398 100644 --- a/messages/src/msg_fields/protocols/present_proof/v2/request.rs +++ b/messages/src/msg_fields/protocols/present_proof/v2/request.rs @@ -2,11 +2,8 @@ use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ - decorators::{ - attachment::{Attachment, AttachmentFormatSpecifier}, - thread::Thread, - timing::Timing, - }, + decorators::{attachment::Attachment, thread::Thread, timing::Timing}, + msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; diff --git a/messages/src/msg_types/registry.rs b/messages/src/msg_types/registry.rs index d0c77459a2..addd216948 100644 --- a/messages/src/msg_types/registry.rs +++ b/messages/src/msg_types/registry.rs @@ -4,21 +4,24 @@ use lazy_static::lazy_static; use shared_vcx::maybe_known::MaybeKnown; use super::{role::Role, Protocol}; -use crate::msg_types::{protocols::{ - basic_message::BasicMessageTypeV1, - connection::ConnectionTypeV1, - cred_issuance::{CredentialIssuanceTypeV1, CredentialIssuanceTypeV2}, - discover_features::DiscoverFeaturesTypeV1, - notification::NotificationTypeV1, - out_of_band::OutOfBandTypeV1, - pickup::PickupTypeV2, - present_proof::PresentProofTypeV1, - report_problem::ReportProblemTypeV1, - revocation::RevocationTypeV2, - routing::RoutingTypeV1, - signature::SignatureTypeV1, - trust_ping::TrustPingTypeV1, -}, present_proof::PresentProofTypeV2}; +use crate::msg_types::{ + present_proof::PresentProofTypeV2, + protocols::{ + basic_message::BasicMessageTypeV1, + connection::ConnectionTypeV1, + cred_issuance::{CredentialIssuanceTypeV1, CredentialIssuanceTypeV2}, + discover_features::DiscoverFeaturesTypeV1, + notification::NotificationTypeV1, + out_of_band::OutOfBandTypeV1, + pickup::PickupTypeV2, + present_proof::PresentProofTypeV1, + report_problem::ReportProblemTypeV1, + revocation::RevocationTypeV2, + routing::RoutingTypeV1, + signature::SignatureTypeV1, + trust_ping::TrustPingTypeV1, + }, +}; type RegistryMap = HashMap<(&'static str, u8), Vec>; /// An entry in the protocol registry.