1use foctet_core::BodyEnvelopeLimits;
2
3#[derive(Clone, Debug, Eq, PartialEq)]
5pub struct HttpConfig {
6 strip_content_type_on_open: bool,
7 set_scope_header_on_seal: bool,
8}
9
10impl Default for HttpConfig {
11 fn default() -> Self {
12 Self {
13 strip_content_type_on_open: true,
14 set_scope_header_on_seal: true,
15 }
16 }
17}
18
19impl HttpConfig {
20 pub fn new() -> Self {
22 Self::default()
23 }
24
25 pub fn strip_content_type_on_open(&self) -> bool {
27 self.strip_content_type_on_open
28 }
29
30 pub fn set_scope_header_on_seal(&self) -> bool {
32 self.set_scope_header_on_seal
33 }
34
35 pub fn with_strip_content_type_on_open(mut self, value: bool) -> Self {
37 self.strip_content_type_on_open = value;
38 self
39 }
40
41 pub fn with_scope_header_on_seal(mut self, value: bool) -> Self {
43 self.set_scope_header_on_seal = value;
44 self
45 }
46}
47
48#[derive(Clone, Debug, Eq, PartialEq)]
50pub struct HttpSealOptions {
51 recipient_public_key: [u8; 32],
52 recipient_key_id: Vec<u8>,
53 limits: Option<BodyEnvelopeLimits>,
54}
55
56impl HttpSealOptions {
57 pub fn new(recipient_public_key: [u8; 32], recipient_key_id: impl AsRef<[u8]>) -> Self {
59 Self {
60 recipient_public_key,
61 recipient_key_id: recipient_key_id.as_ref().to_vec(),
62 limits: None,
63 }
64 }
65
66 pub fn with_limits(mut self, limits: BodyEnvelopeLimits) -> Self {
68 self.limits = Some(limits);
69 self
70 }
71
72 pub fn recipient_public_key(&self) -> [u8; 32] {
74 self.recipient_public_key
75 }
76
77 pub fn recipient_key_id(&self) -> &[u8] {
79 &self.recipient_key_id
80 }
81
82 pub fn limits(&self) -> Option<&BodyEnvelopeLimits> {
84 self.limits.as_ref()
85 }
86}
87
88#[derive(Clone, Debug, Eq, PartialEq)]
90pub struct HttpOpenOptions {
91 recipient_secret_key: [u8; 32],
92 limits: Option<BodyEnvelopeLimits>,
93}
94
95impl HttpOpenOptions {
96 pub fn new(recipient_secret_key: [u8; 32]) -> Self {
98 Self {
99 recipient_secret_key,
100 limits: None,
101 }
102 }
103
104 pub fn with_limits(mut self, limits: BodyEnvelopeLimits) -> Self {
106 self.limits = Some(limits);
107 self
108 }
109
110 pub fn recipient_secret_key(&self) -> [u8; 32] {
112 self.recipient_secret_key
113 }
114
115 pub fn limits(&self) -> Option<&BodyEnvelopeLimits> {
117 self.limits.as_ref()
118 }
119}