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

Method as_aligned_slice

nodedb-wal/src/align.rs:118–123  ·  view source on GitHub ↗

Get the written portion padded up to the next alignment boundary. O_DIRECT requires the I/O size to be a multiple of the block size. The padding bytes are zeroed (from `alloc_zeroed`).

(&self)

Source from the content-addressed store, hash-verified

116 /// O_DIRECT requires the I/O size to be a multiple of the block size.
117 /// The padding bytes are zeroed (from `alloc_zeroed`).
118 pub fn as_aligned_slice(&self) -> &[u8] {
119 let aligned_len = round_up(self.len, self.alignment);
120 let actual_len = aligned_len.min(self.capacity);
121 // SAFETY: ptr is valid for `capacity` bytes, and actual_len <= capacity.
122 unsafe { std::slice::from_raw_parts(self.ptr, actual_len) }
123 }
124
125 /// Reset the buffer for reuse without deallocating.
126 pub fn clear(&mut self) {

Callers 2

flush_bufferMethod · 0.80
submit_and_wait_writeMethod · 0.80

Calls 1

round_upFunction · 0.70

Tested by

no test coverage detected