pub struct State(/* private fields */);Expand description
The serialisable state of an in-memory index.
Maps community names to their indexed packages.
§Examples
use loadsmith_thunderstore::in_memory::State;
let state = State::default();Implementations§
Source§impl State
impl State
Sourcepub fn get<'a>(&'a self, id: &PackageId) -> Result<Option<&'a PackageV1>>
pub fn get<'a>(&'a self, id: &PackageId) -> Result<Option<&'a PackageV1>>
Looks up a package across all indexed communities.
Returns IndexNotComplete if any community index has not finished
fetching.
§Examples
use loadsmith_thunderstore::in_memory::State;
use loadsmith_core::PackageId;
let state = State::default();
let result = state.get(&PackageId::new("Unknown-Pkg"));
assert!(result.is_err()); // index is not completeSourcepub fn community_mut(&mut self, community: impl Into<String>) -> &mut Community
pub fn community_mut(&mut self, community: impl Into<String>) -> &mut Community
Returns a mutable reference to the community entry, creating it if it does not exist.
§Examples
use loadsmith_thunderstore::in_memory::State;
let mut state = State::default();
let community = state.community_mut("rounds");Trait Implementations§
Source§impl<'de> Deserialize<'de> for State
impl<'de> Deserialize<'de> for State
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for State
impl RefUnwindSafe for State
impl Send for State
impl Sync for State
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for State
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