MCPcopy Create free account
hub / github.com/Slowerzs/PPLSystem / get_ref_from_buffer

Function get_ref_from_buffer

src/kdmp/parser.rs:443–453  ·  view source on GitHub ↗
(buf: &[u8])

Source from the content-addressed store, hash-verified

441}
442
443fn get_ref_from_buffer<T>(buf: &[u8]) -> Result<&T, ParsingError> {
444 if buf.len() < size_of::<T>() {
445 return Err(ParsingError::BufferTooSmall);
446 }
447
448 if (buf.as_ptr() as usize) % std::mem::align_of::<T>() != 0 {
449 return Err(ParsingError::BadAlignment);
450 }
451
452 Ok(unsafe { &*(buf.as_ptr() as *const T) })
453}
454
455fn get_dump_headers_from_buffer(buf: &[u8]) -> Result<&DUMP_HEADER64, ParsingError> {
456 let headers: &DUMP_HEADER64 = get_ref_from_buffer(buf)?;

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected