1 // Copyright 2023 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 mod descriptor; 6 mod memory_mapping; 7 mod shm; 8 pub mod sys; 9 10 pub use descriptor::AsRawDescriptor; 11 pub use descriptor::AsRawDescriptors; 12 pub use descriptor::FromRawDescriptor; 13 pub use descriptor::IntoRawDescriptor; 14 pub use descriptor::SafeDescriptor; 15 pub use memory_mapping::MemoryMapping; 16 pub use shm::SharedMemory; 17 pub use sys::platform::descriptor::RawDescriptor; 18 pub use sys::platform::shm::round_up_to_page_size; 19 20 /// # Safety 21 /// 22 /// Caller must ensure that MappedRegion's lifetime contains the lifetime of 23 /// pointer returned. 24 pub unsafe trait MappedRegion: Send + Sync { 25 /// Returns a pointer to the beginning of the memory region. Should only be 26 /// used for passing this region to ioctls for setting guest memory. as_ptr(&self) -> *mut u827 fn as_ptr(&self) -> *mut u8; 28 29 /// Returns the size of the memory region in bytes. size(&self) -> usize30 fn size(&self) -> usize; 31 } 32