(&self, append_length: bool, code: Option<u8>)
| 60 | } |
| 61 | |
| 62 | pub fn join(&self, append_length: bool, code: Option<u8>) -> Vec<u8> { |
| 63 | let body_len: usize = self.buffers.iter().map(|b| b.len()).sum(); |
| 64 | let mut result = Vec::with_capacity( |
| 65 | body_len + usize::from(append_length) * 4 + usize::from(code.is_some()), |
| 66 | ); |
| 67 | |
| 68 | if let Some(code) = code { |
| 69 | result.push(code); |
| 70 | } |
| 71 | |
| 72 | if append_length { |
| 73 | let length = (body_len + 4) as i32; |
| 74 | result.extend_from_slice(&length.to_be_bytes()); |
| 75 | } |
| 76 | |
| 77 | for part in &self.buffers { |
| 78 | result.extend_from_slice(part); |
| 79 | } |
| 80 | |
| 81 | result |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | pub fn concat_slices(parts: &[&[u8]]) -> Vec<u8> { |
no test coverage detected