Skip to content

Commit bab67f7

Browse files
committed
refactor(decompression-plz): remove unnecessary code in DecodeStruct
1 parent e7301d8 commit bab67f7

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed

decompression-plz/src/decode_struct.rs

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub struct DecodeStruct<'a, T> {
1414
pub message: &'a mut T,
1515
pub body: BytesMut,
1616
pub extra_body: Option<BytesMut>,
17-
body_headers: Option<BodyHeader>,
17+
pub body_headers: Option<BodyHeader>,
1818
pub buf: &'a mut BytesMut,
1919
}
2020

@@ -69,33 +69,20 @@ where
6969
.is_some()
7070
}
7171

72-
pub fn is_chunked_te_only(&self) -> bool {
73-
self.body_headers
74-
.as_ref()
75-
.map(|bh| bh.is_chunked_te_only())
76-
.unwrap_or(false)
77-
}
78-
79-
pub fn is_identity_te_only(&self) -> bool {
80-
self.body_headers
81-
.as_ref()
82-
.map(|bh| bh.is_identity_te_only())
83-
.unwrap_or(false)
72+
pub fn get_transfer_encoding(&mut self) -> Vec<EncodingInfo> {
73+
self.body_headers.as_mut().unwrap().transfer_encoding.take().unwrap()
8474
}
8575

86-
pub fn is_identity_ce_only(&self) -> bool {
87-
self.body_headers
88-
.as_ref()
89-
.map(|bh| bh.is_identity_ce_only())
90-
.unwrap_or(false)
76+
pub fn get_content_encoding(&mut self) -> Vec<EncodingInfo> {
77+
self.body_headers.as_mut().unwrap().content_encoding.take().unwrap()
9178
}
9279

93-
pub fn transfer_encoding(&mut self) -> Vec<EncodingInfo> {
94-
self.body_headers.as_mut().unwrap().transfer_encoding.take().unwrap()
80+
pub fn set_transfer_encoding(&mut self, te: Vec<EncodingInfo>) {
81+
self.body_headers.as_mut().unwrap().transfer_encoding = Some(te);
9582
}
9683

97-
pub fn content_encoding(&mut self) -> Vec<EncodingInfo> {
98-
self.body_headers.as_mut().unwrap().content_encoding.take().unwrap()
84+
pub fn set_content_encoding(&mut self, ce: Vec<EncodingInfo>) {
85+
self.body_headers.as_mut().unwrap().content_encoding = Some(ce);
9986
}
10087

10188
pub fn extra_body_is_some(&self) -> bool {

0 commit comments

Comments
 (0)