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

Method write

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

Write bytes into the buffer. Returns the number of bytes written. If the buffer doesn't have enough remaining capacity, writes as much as possible and returns the count.

(&mut self, data: &[u8])

Source from the content-addressed store, hash-verified

91 /// If the buffer doesn't have enough remaining capacity, writes as much
92 /// as possible and returns the count.
93 pub fn write(&mut self, data: &[u8]) -> usize {
94 let available = self.capacity - self.len;
95 let to_write = data.len().min(available);
96 if to_write > 0 {
97 // SAFETY: ptr + len is within the allocation, and to_write <= available.
98 unsafe {
99 std::ptr::copy_nonoverlapping(data.as_ptr(), self.ptr.add(self.len), to_write);
100 }
101 self.len += to_write;
102 }
103 to_write
104 }
105
106 /// Get the written portion of the buffer as a byte slice.
107 ///

Callers 15

set_database_budgetMethod · 0.45
clear_database_budgetMethod · 0.45
set_tenant_budgetMethod · 0.45
clear_tenant_budgetMethod · 0.45
openMethod · 0.45
write_record_deferredMethod · 0.45
flushMethod · 0.45
openMethod · 0.45
set_encryption_ringMethod · 0.45

Calls 3

lenMethod · 0.45
as_ptrMethod · 0.45
addMethod · 0.45