| 172 | |
| 173 | #[inline] |
| 174 | pub async fn insert<K, Doc>(&self, key: K, doc: Doc) -> Result<(), SessionResult> |
| 175 | where |
| 176 | Doc: Serialize + DeserializeOwned + Clone + Send + 'static + Document, |
| 177 | K: Serialize |
| 178 | + DeserializeOwned |
| 179 | + PartialOrd |
| 180 | + Ord |
| 181 | + PartialEq |
| 182 | + Eq |
| 183 | + Hash |
| 184 | + Clone |
| 185 | + Send |
| 186 | + Sync |
| 187 | + 'static |
| 188 | { |
| 189 | match self.datastores.get::<Storage<K, Doc>>() { |
| 190 | None => Err(SessionResult::DataStoreNotFound), |
| 191 | Some(datastore) => { |
| 192 | datastore.insert(key, doc).await |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | #[inline] |
| 198 | pub async fn remove<K, Doc>(&self, key: K) -> Result<(), SessionResult> |