diff --git a/snapfile/src/page.rs b/snapfile/src/page.rs index 625dd64b8f..08a5a9afc6 100644 --- a/snapfile/src/page.rs +++ b/snapfile/src/page.rs @@ -1,6 +1,16 @@ /// A single 8KB page. pub struct Page(pub Box<[u8; 8192]>); +impl Page { + /// Create a page by copying bytes from another slice. + /// + /// This is a copy, not a move. If the caller already has + /// an owned array then `From<[u8; 8192]>` can be used instead. + pub fn copy_slice(x: &[u8; 8192]) -> Self { + Page(Box::new(x.clone())) + } +} + impl Default for Page { fn default() -> Self { Page(Box::new([0u8; 8192]))