pub struct ZaddFlags { /* private fields */ }Expand description
Parsed ZADD condition flags: NX / XX as a SetCondition,
GT / LT as a ScoreCompare, and CH. Only Redis’s legal
combinations can be built — ZaddFlags::new refuses NX with
GT / LT — so the store never has a combination to reject. CH
only changes the reply (changed count instead of added count);
ZaddReport carries both counts either way.
use kevy_store::{ScoreCompare, SetCondition, ZaddFlags};
let f = ZaddFlags::new(SetCondition::IfPresent, ScoreCompare::Greater).unwrap().with_ch(true);
assert_eq!((f.condition(), f.compare(), f.ch()), (SetCondition::IfPresent, ScoreCompare::Greater, true));
assert!(ZaddFlags::new(SetCondition::IfAbsent, ScoreCompare::Less).is_none());
assert_eq!(ZaddFlags::default(), ZaddFlags::new(SetCondition::Always, ScoreCompare::Any).unwrap());Implementations§
Source§impl ZaddFlags
impl ZaddFlags
Sourcepub fn new(condition: SetCondition, compare: ScoreCompare) -> Option<ZaddFlags>
pub fn new(condition: SetCondition, compare: ScoreCompare) -> Option<ZaddFlags>
The flags for condition and compare, or None for the one
combination Redis refuses: NX together with GT or LT.
Sourcepub fn with_ch(self, ch: bool) -> ZaddFlags
pub fn with_ch(self, ch: bool) -> ZaddFlags
Set CH: the reply counts changed members instead of added ones.
assert!(kevy_store::ZaddFlags::default().with_ch(true).ch());Sourcepub fn condition(self) -> SetCondition
pub fn condition(self) -> SetCondition
NX / XX, or neither.
Sourcepub fn compare(self) -> ScoreCompare
pub fn compare(self) -> ScoreCompare
GT / LT, or neither.
Trait Implementations§
impl Copy for ZaddFlags
impl Eq for ZaddFlags
impl StructuralPartialEq for ZaddFlags
Auto Trait Implementations§
impl Freeze for ZaddFlags
impl RefUnwindSafe for ZaddFlags
impl Send for ZaddFlags
impl Sync for ZaddFlags
impl Unpin for ZaddFlags
impl UnsafeUnpin for ZaddFlags
impl UnwindSafe for ZaddFlags
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