iscc_lib/types.rs
1//! Structured result types for ISCC code generation functions.
2//!
3//! Each `gen_*_v0` function returns a dedicated result struct carrying the ISCC
4//! code string plus any additional fields (metahash, name, characters, etc.)
5//! that match the `iscc-core` Python reference implementation's dict returns.
6
7/// Result of [`gen_meta_code_v0`](crate::gen_meta_code_v0).
8#[derive(Debug, Clone, PartialEq, Eq)]
9#[non_exhaustive]
10pub struct MetaCodeResult {
11 /// ISCC code string (e.g., `"ISCC:AAAZXZ6OU74YAZIM"`).
12 pub iscc: String,
13 /// Normalized name after cleaning, newline removal, and trimming.
14 pub name: String,
15 /// Normalized description (present only when description was non-empty).
16 pub description: Option<String>,
17 /// Metadata as a Data-URL string (present only when meta was provided).
18 pub meta: Option<String>,
19 /// Hex-encoded BLAKE3 multihash (`"1e20..."`) of the metadata payload.
20 pub metahash: String,
21}
22
23/// Result of [`gen_text_code_v0`](crate::gen_text_code_v0).
24#[derive(Debug, Clone, PartialEq, Eq)]
25#[non_exhaustive]
26pub struct TextCodeResult {
27 /// ISCC code string.
28 pub iscc: String,
29 /// Character count after `text_collapse`.
30 pub characters: usize,
31}
32
33/// Result of [`gen_image_code_v0`](crate::gen_image_code_v0).
34#[derive(Debug, Clone, PartialEq, Eq)]
35#[non_exhaustive]
36pub struct ImageCodeResult {
37 /// ISCC code string.
38 pub iscc: String,
39}
40
41/// Result of [`gen_audio_code_v0`](crate::gen_audio_code_v0).
42#[derive(Debug, Clone, PartialEq, Eq)]
43#[non_exhaustive]
44pub struct AudioCodeResult {
45 /// ISCC code string.
46 pub iscc: String,
47}
48
49/// Result of [`gen_video_code_v0`](crate::gen_video_code_v0).
50#[derive(Debug, Clone, PartialEq, Eq)]
51#[non_exhaustive]
52pub struct VideoCodeResult {
53 /// ISCC code string.
54 pub iscc: String,
55}
56
57/// Result of [`gen_mixed_code_v0`](crate::gen_mixed_code_v0).
58#[derive(Debug, Clone, PartialEq, Eq)]
59#[non_exhaustive]
60pub struct MixedCodeResult {
61 /// ISCC code string.
62 pub iscc: String,
63 /// Input Content-Code strings (passed through unchanged).
64 pub parts: Vec<String>,
65}
66
67/// Result of [`gen_data_code_v0`](crate::gen_data_code_v0).
68#[derive(Debug, Clone, PartialEq, Eq)]
69#[non_exhaustive]
70pub struct DataCodeResult {
71 /// ISCC code string.
72 pub iscc: String,
73}
74
75/// Result of [`gen_instance_code_v0`](crate::gen_instance_code_v0).
76#[derive(Debug, Clone, PartialEq, Eq)]
77#[non_exhaustive]
78pub struct InstanceCodeResult {
79 /// ISCC code string.
80 pub iscc: String,
81 /// Hex-encoded BLAKE3 multihash (`"1e20..."`) of the input data.
82 pub datahash: String,
83 /// Byte length of the input data.
84 pub filesize: u64,
85}
86
87/// Result of [`gen_iscc_code_v0`](crate::gen_iscc_code_v0).
88#[derive(Debug, Clone, PartialEq, Eq)]
89#[non_exhaustive]
90pub struct IsccCodeResult {
91 /// ISCC code string.
92 pub iscc: String,
93}