Skip to content

Commit 1cd0243

Browse files
committed
wip(rust/signed_doc): add API methods to get document metadata uuids
1 parent 3a6795d commit 1cd0243

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

rust/signed_doc/src/lib.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub struct CatalystSignedDocument {
1515
/// Inner type that holds the Catalyst Signed Document with parsing errors.
1616
struct InnerCatalystSignedDocument {
1717
/// Document Metadata
18-
_metadata: Metadata,
18+
metadata: Metadata,
1919
/// Raw payload
2020
_raw_doc: Vec<u8>,
2121
}
@@ -64,14 +64,15 @@ pub enum DocumentRef {
6464
impl TryFrom<Vec<u8>> for CatalystSignedDocument {
6565
type Error = &'static str;
6666

67-
fn try_from(value: Vec<u8>) -> Result<Self, Self::Error> {
67+
#[allow(clippy::todo)]
68+
fn try_from(_value: Vec<u8>) -> Result<Self, Self::Error> {
6869
todo!();
6970
}
7071
}
7172

7273
impl CatalystSignedDocument {
7374
/// Invalid Doc Type UUID
74-
const INVALID_UUID: uuid::Uuid = uuid::Uuid::from_bytes([0x00; 16]);
75+
const _INVALID_UUID: uuid::Uuid = uuid::Uuid::from_bytes([0x00; 16]);
7576

7677
// A bunch of getters to access the contents, or reason through the document, such as.
7778

@@ -81,9 +82,15 @@ impl CatalystSignedDocument {
8182
!self.content_errors.is_empty()
8283
}
8384

84-
/// Return Document Type UUID.
85+
/// Return Document Type `UUIDv4`.
8586
#[must_use]
8687
pub fn doc_type(&self) -> uuid::Uuid {
87-
INVALID_UUID
88-
} // Can compare it against INVALID_DOC_TYPE to see if its valid or not.
88+
self.inner.metadata.r#type
89+
}
90+
91+
/// Return Document ID `UUIDv7`.
92+
#[must_use]
93+
pub fn doc_id(&self) -> uuid::Uuid {
94+
self.inner.metadata.id
95+
}
8996
}

0 commit comments

Comments
 (0)