MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / full_capacity_slice

Function full_capacity_slice

nodedb-wal/src/double_write.rs:436–440  ·  view source on GitHub ↗

View the entire allocated capacity of `buf` as a byte slice. Requires that the caller has zeroed any unwritten tail (see `zero_tail`).

(buf: &AlignedBuf)

Source from the content-addressed store, hash-verified

434/// View the entire allocated capacity of `buf` as a byte slice. Requires
435/// that the caller has zeroed any unwritten tail (see `zero_tail`).
436fn full_capacity_slice(buf: &AlignedBuf) -> &[u8] {
437 // SAFETY: AlignedBuf guarantees `as_ptr` points to `capacity()` valid
438 // bytes (alloc_zeroed) for the lifetime of the buffer.
439 unsafe { std::slice::from_raw_parts(buf.as_ptr(), buf.capacity()) }
440}
441
442/// `pwrite`-retry helper that handles short writes.
443fn pwrite_all(file: &File, data: &[u8], offset: u64) -> Result<()> {

Callers 2

write_record_deferredMethod · 0.85
flushMethod · 0.85

Calls 2

as_ptrMethod · 0.45
capacityMethod · 0.45

Tested by

no test coverage detected