Skip to content

Commit

Permalink
RE review: move attachment format specifier
Browse files Browse the repository at this point in the history
Signed-off-by: George Mulhearn <[email protected]>
  • Loading branch information
gmulhearn-anonyome committed Oct 19, 2023
1 parent b4aa4dc commit 92e8ed9
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 70 deletions.
17 changes: 0 additions & 17 deletions messages/src/decorators/attachment.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -59,22 +58,6 @@ pub enum AttachmentType {
Links(Vec<Url>),
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)]
#[serde(rename_all = "snake_case")]
pub struct AttachmentFormatSpecifier<F> {
pub attach_id: String,
pub format: MaybeKnown<F>,
}

#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)]
#[serde(rename_all = "snake_case")]
pub struct OptionalIdAttachmentFormatSpecifier<F> {
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub attach_id: Option<String>,
pub format: MaybeKnown<F>,
}

#[cfg(test)]
#[allow(clippy::unwrap_used)]
#[allow(clippy::field_reassign_with_default)]
Expand Down
2 changes: 1 addition & 1 deletion messages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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<F> {
pub attach_id: String,
pub format: MaybeKnown<F>,
}

/// 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<F> {
#[builder(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub attach_id: Option<String>,
pub format: MaybeKnown<F>,
}
1 change: 1 addition & 0 deletions messages/src/msg_fields/protocols/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod attachment_format_specifier;
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
1 change: 1 addition & 0 deletions messages/src/msg_fields/protocols/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod basic_message;
pub mod common;
pub mod connection;
pub mod cred_issuance;
pub mod discover_features;
Expand Down
8 changes: 2 additions & 6 deletions messages/src/msg_fields/protocols/present_proof/v2/present.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
7 changes: 2 additions & 5 deletions messages/src/msg_fields/protocols/present_proof/v2/propose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
7 changes: 2 additions & 5 deletions messages/src/msg_fields/protocols/present_proof/v2/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};

Expand Down
33 changes: 18 additions & 15 deletions messages/src/msg_types/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<RegistryEntry>>;

/// An entry in the protocol registry.
Expand Down

0 comments on commit 92e8ed9

Please sign in to comment.