nuit_core/state/key.rs
1use serde::{Deserialize, Serialize};
2
3use crate::IdPathBuf;
4
5/// A key that uniquely identifies a value in a storage.
6#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct StateKey {
9 /// The id path of the view holding the state.
10 id_path: IdPathBuf,
11 /// The state index within the view.
12 index: usize,
13}
14
15impl StateKey {
16 pub fn new(id_path: impl Into<IdPathBuf>, index: impl Into<usize>) -> Self {
17 Self { id_path: id_path.into(), index: index.into() }
18 }
19}