bee_storage/access/insert.rs
1// Copyright 2020-2021 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::backend::StorageBackend;
5
6/// `Insert<K, V>` trait extends the `StorageBackend` with `insert` operation for the (key: K, value: V) pair;
7/// therefore, it should be explicitly implemented for the corresponding `StorageBackend`.
8pub trait Insert<K, V>: StorageBackend {
9 /// Inserts the (K, V) pair in the storage overwriting the value if it already exists.
10 fn insert(&self, key: &K, value: &V) -> Result<(), Self::Error>;
11}
12
13/// `InsertStrict<K, V>` trait extends the `StorageBackend` with `insert_strict` operation for the
14/// (key: K, value: V) pair; therefore, it should be explicitly implemented for the corresponding
15/// `StorageBackend`.
16pub trait InsertStrict<K, V>: StorageBackend {
17 /// Inserts the (K, V) pair in the storage without overwriting the value if it already exists.
18 fn insert_strict(&self, key: &K, value: &V) -> Result<(), Self::Error>;
19}