#[non_exhaustive]pub enum StoreError {
WrongType,
NotInteger,
Overflow,
OutOfRange,
NoSuchKey,
NotFloat,
OutOfMemory,
StreamExhausted,
}Expand description
Operation errors surfaced to the command layer.
Display is the lowercase description; StoreError::as_wire is the
Redis error reply text the command layer sends.
use kevy_store::StoreError;
assert_eq!(StoreError::WrongType.to_string(), "wrong type for this operation");
assert!(StoreError::WrongType.as_wire().starts_with("WRONGTYPE "));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
WrongType
Key holds a different type than the command expects.
use kevy_store::{Store, StoreError};
let mut s = Store::new();
s.rpush(b"l", &[b"x".as_slice()])?;
assert_eq!(s.get(b"l"), Err(StoreError::WrongType));NotInteger
Value is not a base-10 integer (INCR family).
use kevy_store::{SetCondition, Store, StoreError};
let mut s = Store::new();
s.set(b"k", b"ten".to_vec(), None, SetCondition::Always);
assert_eq!(s.incr_by(b"k", 1), Err(StoreError::NotInteger));Overflow
Result would overflow i64.
use kevy_store::{SetCondition, Store, StoreError};
let mut s = Store::new();
s.set(b"k", i64::MAX.to_string().into_bytes(), None, SetCondition::Always);
assert_eq!(s.incr_by(b"k", 1), Err(StoreError::Overflow));OutOfRange
Index outside the collection (LSET).
use kevy_store::{Store, StoreError};
let mut s = Store::new();
s.rpush(b"l", &[b"a".as_slice()])?;
assert_eq!(s.lset(b"l", 5, b"x"), Err(StoreError::OutOfRange));NoSuchKey
Key does not exist where the command requires one (LSET).
use kevy_store::{Store, StoreError};
let mut s = Store::new();
assert_eq!(s.lset(b"missing", 0, b"x"), Err(StoreError::NoSuchKey));NotFloat
Value is not a valid float (INCRBYFLOAT).
use kevy_store::{SetCondition, Store, StoreError};
let mut s = Store::new();
s.set(b"k", b"pi".to_vec(), None, SetCondition::Always);
assert_eq!(s.incr_by_float(b"k", 1.0), Err(StoreError::NotFloat));OutOfMemory
maxmemory would be exceeded and the active eviction policy is
EvictionPolicy::NoEviction. Surfaces as Redis’s classic OOM error
at the RESP layer.
use kevy_store::{EvictionPolicy, SetCondition, Store, StoreError};
let mut s = Store::new();
s.set_max_memory(1, EvictionPolicy::NoEviction);
s.set(b"k", b"v".to_vec(), None, SetCondition::Always);
assert_eq!(s.precheck_for_write(), Err(StoreError::OutOfMemory));StreamExhausted
A stream’s last ID is the largest there is, so no entry can follow it (XADD).
use kevy_store::{MissingStream, Store, StoreError, StreamId, XAddIdSpec};
let mut s = Store::new();
let f = || vec![(b"f".to_vec(), b"v".to_vec())];
s.xadd(b"s", XAddIdSpec::Explicit(StreamId::MAX), f(), MissingStream::Create, 0)?;
let next = s.xadd(b"s", XAddIdSpec::AutoAll, f(), MissingStream::Create, 0);
assert_eq!(next, Err(StoreError::StreamExhausted));Implementations§
Trait Implementations§
Source§impl Clone for StoreError
impl Clone for StoreError
Source§fn clone(&self) -> StoreError
fn clone(&self) -> StoreError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for StoreError
Source§impl Debug for StoreError
impl Debug for StoreError
Source§impl Display for StoreError
impl Display for StoreError
impl Eq for StoreError
Source§impl Error for StoreError
impl Error for StoreError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Source§impl From<StoreError> for KevyError
impl From<StoreError> for KevyError
Source§fn from(e: StoreError) -> KevyError
fn from(e: StoreError) -> KevyError
Converts to this type from the input type.
Source§impl Hash for StoreError
impl Hash for StoreError
Source§impl PartialEq for StoreError
impl PartialEq for StoreError
impl StructuralPartialEq for StoreError
Auto Trait Implementations§
impl Freeze for StoreError
impl RefUnwindSafe for StoreError
impl Send for StoreError
impl Sync for StoreError
impl Unpin for StoreError
impl UnsafeUnpin for StoreError
impl UnwindSafe for StoreError
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