pub struct RamOnlyStorage {
saved_chunks: AsyncRwLock<FxHashMap<ChunkPos, SimpleRAMChunk>>,
}Expand description
In-memory chunk storage.
This storage implementation doesn’t persist any data to disk. It’s designed for test worlds and minigame worlds:
- It has chunk generation which can be disabled with
EmptyChunkGen - It will save all the data so perfectly for minigames
TODO: Will later have the option to load a world from storage and clone it for easy world handling
Fields§
§saved_chunks: AsyncRwLock<FxHashMap<ChunkPos, SimpleRAMChunk>>This saves every chunk, and it saves the changes in the world to make it possible to run the server fully in memory
Implementations§
Source§impl RamOnlyStorage
impl RamOnlyStorage
Sourcepub fn empty_world() -> Self
pub fn empty_world() -> Self
Creates a new RAM-only storage which can be used for minigames, etc.
This should be used for a RAM storage solution of a map and every world generation should be supported
Sourcepub async fn load_chunk(
&self,
pos: ChunkPos,
min_y: i32,
height: i32,
level: Weak<World>,
) -> Result<Option<LoadedChunk>>
pub async fn load_chunk( &self, pos: ChunkPos, min_y: i32, height: i32, level: Weak<World>, ) -> Result<Option<LoadedChunk>>
Loads a chunk from storage.
Sourcepub async fn save_chunk_data(&self, prepared: PreparedChunkSave) -> Result<bool>
pub async fn save_chunk_data(&self, prepared: PreparedChunkSave) -> Result<bool>
Saves prepared chunk data to storage.
Sourcepub async fn chunk_exists(&self, pos: ChunkPos) -> Result<bool>
pub async fn chunk_exists(&self, pos: ChunkPos) -> Result<bool>
Checks if a chunk exists in storage.
Auto Trait Implementations§
impl !Freeze for RamOnlyStorage
impl !RefUnwindSafe for RamOnlyStorage
impl Send for RamOnlyStorage
impl Sync for RamOnlyStorage
impl Unpin for RamOnlyStorage
impl UnsafeUnpin for RamOnlyStorage
impl UnwindSafe for RamOnlyStorage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreWraps this value in an
Arc<SyncMutex<>>