core_invoice/
identifier.rs1use std::fmt;
4
5#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8pub struct Identifier {
9 pub value: String,
11 pub scheme: Option<String>,
13 pub scheme_version: Option<String>,
15}
16
17impl Identifier {
18 pub fn new(value: impl Into<String>) -> Self {
20 Self {
21 value: value.into(),
22 scheme: None,
23 scheme_version: None,
24 }
25 }
26
27 pub fn schemed(value: impl Into<String>, scheme: impl Into<String>) -> Self {
29 Self {
30 value: value.into(),
31 scheme: Some(scheme.into()),
32 scheme_version: None,
33 }
34 }
35
36 pub fn with_version(
38 value: impl Into<String>,
39 scheme: impl Into<String>,
40 version: impl Into<String>,
41 ) -> Self {
42 Self {
43 value: value.into(),
44 scheme: Some(scheme.into()),
45 scheme_version: Some(version.into()),
46 }
47 }
48}
49
50#[derive(Debug, Clone, PartialEq, Eq, Hash)]
52pub struct DocumentReference(
53 pub String,
55);
56
57impl DocumentReference {
58 pub fn new(value: impl Into<String>) -> Self {
60 Self(value.into())
61 }
62
63 pub fn as_str(&self) -> &str {
65 &self.0
66 }
67}
68
69impl fmt::Display for DocumentReference {
70 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
71 self.0.fmt(f)
72 }
73}