nucypher_core/
conditions.rs1use alloc::string::String;
2use core::fmt;
3
4use serde::{Deserialize, Serialize};
5
6#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
8pub struct Conditions(String);
9
10impl Conditions {
11 pub fn new(conditions: &str) -> Self {
13 Self(conditions.into())
14 }
15}
16
17impl AsRef<str> for Conditions {
18 fn as_ref(&self) -> &str {
19 self.0.as_ref()
20 }
21}
22
23impl From<String> for Conditions {
24 fn from(source: String) -> Self {
25 Self(source)
26 }
27}
28
29impl fmt::Display for Conditions {
30 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
31 write!(f, "{}", self.0)
32 }
33}
34
35#[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
37pub struct Context(String);
38
39impl Context {
40 pub fn new(context: &str) -> Self {
42 Self(context.into())
43 }
44}
45
46impl AsRef<str> for Context {
47 fn as_ref(&self) -> &str {
48 self.0.as_ref()
49 }
50}
51
52impl From<String> for Context {
53 fn from(source: String) -> Self {
54 Self(source)
55 }
56}
57
58impl fmt::Display for Context {
59 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
60 write!(f, "{}", self.0)
61 }
62}