ankurah_proto/
collection.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
4pub struct CollectionId(String);
5
6impl CollectionId {
7 pub fn fixed_name(name: &str) -> Self { CollectionId(name.to_string()) }
9}
10
11impl From<&str> for CollectionId {
12 fn from(val: &str) -> Self { CollectionId(val.to_string()) }
13}
14impl PartialEq<str> for CollectionId {
15 fn eq(&self, other: &str) -> bool { self.0 == other }
16}
17
18impl From<String> for CollectionId {
19 fn from(val: String) -> Self { CollectionId(val) }
20}
21impl From<CollectionId> for String {
22 fn from(collection_id: CollectionId) -> Self { collection_id.0 }
23}
24impl AsRef<str> for CollectionId {
25 fn as_ref(&self) -> &str { &self.0 }
26}
27
28impl CollectionId {
29 pub fn as_str(&self) -> &str { &self.0 }
30}
31
32impl std::fmt::Display for CollectionId {
33 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.0) }
34}