core_invoice/
identifier.rs1use std::fmt;
2
3#[derive(Debug, Clone, PartialEq, Eq, Hash)]
6pub struct Identifier {
7 pub value: String,
8 pub scheme: Option<String>,
9 pub scheme_version: Option<String>,
10}
11
12impl Identifier {
13 pub fn new(value: impl Into<String>) -> Self {
14 Self {
15 value: value.into(),
16 scheme: None,
17 scheme_version: None,
18 }
19 }
20
21 pub fn schemed(value: impl Into<String>, scheme: impl Into<String>) -> Self {
22 Self {
23 value: value.into(),
24 scheme: Some(scheme.into()),
25 scheme_version: None,
26 }
27 }
28
29 pub fn with_version(
30 value: impl Into<String>,
31 scheme: impl Into<String>,
32 version: impl Into<String>,
33 ) -> Self {
34 Self {
35 value: value.into(),
36 scheme: Some(scheme.into()),
37 scheme_version: Some(version.into()),
38 }
39 }
40}
41
42#[derive(Debug, Clone, PartialEq, Eq, Hash)]
44pub struct DocumentReference(pub String);
45
46impl DocumentReference {
47 pub fn new(value: impl Into<String>) -> Self {
48 Self(value.into())
49 }
50
51 pub fn as_str(&self) -> &str {
52 &self.0
53 }
54}
55
56impl fmt::Display for DocumentReference {
57 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
58 self.0.fmt(f)
59 }
60}