MCPcopy Index your code
hub / github.com/FrameworkComputer/framework-system / print_multiline_buffer

Function print_multiline_buffer

framework_lib/src/util.rs:239–256  ·  view source on GitHub ↗

Print a big byte buffer Because it's long it'll be printed in several lines, each 16 bytes Example print_multiline_buffer(&[0xa0, 0x00, 0x00, 0x36, 0x62, 0x6e, 0x03, 0x00, 0xc5, 0x11, 0x80, 0x35, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], 0x2000) Output: 00002000: a000 0036 626e 0300 c511 8035 0000 0000 ...6bn.....5.... 00

(buffer: &[u8], offset: usize)

Source from the content-addressed store, hash-verified

237/// 00002000: a000 0036 626e 0300 c511 8035 0000 0000 ...6bn.....5....
238/// 00002010: 0000 0000 0000 0000 0000 0000 0000 00 ................
239pub fn print_multiline_buffer(buffer: &[u8], offset: usize) {
240 let chunk_size = 16;
241 for (i, chunk) in buffer.chunks(chunk_size).enumerate() {
242 print!("{:08x}:", offset + i * chunk_size);
243 print_chunk(chunk, false);
244
245 // Make sure ASCII section aligns, even if less than 16 byte chunks
246 if chunk.len() < 16 {
247 let byte_padding = 16 - chunk.len();
248 let space_padding = byte_padding / 2;
249 let padding = byte_padding * 2 + space_padding;
250 print!("{}", " ".repeat(padding));
251 }
252 print!(" ");
253
254 print_ascii_buffer(chunk, true);
255 }
256}
257
258/// Find a sequence of bytes in a long slice of bytes
259pub fn find_sequence(haystack: &[u8], needle: &[u8]) -> Option<usize> {

Callers 7

transfer_readFunction · 0.85
checksum_buffersFunction · 0.85
checksum_bufferFunction · 0.85
transfer_writeFunction · 0.85
transfer_readFunction · 0.85
run_with_argsFunction · 0.85
selftestFunction · 0.85

Calls 2

print_chunkFunction · 0.85
print_ascii_bufferFunction · 0.85

Tested by

no test coverage detected