rusty_cdk_core/shared/
mod.rs1use std::fmt::{Display, Formatter};
2use std::ops::Deref;
3
4pub mod http;
5pub mod macros;
6
7#[derive(Debug, Clone)]
8pub struct Id(pub String);
9
10impl Deref for Id {
11 type Target = str;
12
13 fn deref(&self) -> &Self::Target {
14 self.0.as_str()
15 }
16}
17
18impl Display for Id {
19 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
20 f.write_str(self.0.as_str())
21 }
22}
23
24impl Id {
25 pub fn generate_id(id: &Id, suffix: &str) -> Id {
26 Id(format!("{}{}", id.0, suffix))
27 }
28
29 pub fn combine_ids(first: &Id, second: &Id) -> Id {
30 Id(format!("{}{}", first.0, second.0))
31 }
32
33 pub fn combine_with_resource_id(first: &Id, second: &str) -> Id {
34 Id(format!("{}{}", first.0, second))
35 }
36}