MCPcopy Create free account
hub / github.com/RustCrypto/formats / fill_block_buffer

Method fill_block_buffer

base64ct/src/decoder.rs:198–227  ·  view source on GitHub ↗

Fill the block buffer with data.

(&mut self)

Source from the content-addressed store, hash-verified

196
197 /// Fill the block buffer with data.
198 fn fill_block_buffer(&mut self) -> Result<(), Error> {
199 let mut buf = [0u8; BlockBuffer::SIZE];
200
201 let decoded = if self.line.len() < 4 && !self.line_reader.is_empty() {
202 // Handle input block which is split across lines
203 let mut tmp = [0u8; 4];
204
205 // Copy remaining data in the line into tmp
206 let line_end = self.line.take(4);
207 tmp[..line_end.len()].copy_from_slice(line_end);
208
209 // Advance the line and attempt to fill tmp
210 self.advance_line()?;
211 let len = 4usize.checked_sub(line_end.len()).ok_or(InvalidLength)?;
212 let line_begin = self.line.take(len);
213 tmp[line_end.len()..][..line_begin.len()].copy_from_slice(line_begin);
214
215 let tmp_len = line_begin
216 .len()
217 .checked_add(line_end.len())
218 .ok_or(InvalidLength)?;
219
220 self.perform_decode(&tmp[..tmp_len], &mut buf)
221 } else {
222 let block = self.line.take(4);
223 self.perform_decode(block, &mut buf)
224 }?;
225
226 self.block_buffer.fill(decoded)
227 }
228
229 /// Advance the internal buffer to the next line.
230 fn advance_line(&mut self) -> Result<(), Error> {

Callers 1

decodeMethod · 0.80

Calls 6

advance_lineMethod · 0.80
perform_decodeMethod · 0.80
lenMethod · 0.45
is_emptyMethod · 0.45
takeMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected