#[non_exhaustive]pub enum CopyMode {
IfAbsent,
Replace,
}Expand description
Whether COPY may overwrite an existing destination
(crate::Store::copy).
use kevy_embedded::{Config, CopyMode, Store};
let s = Store::open(Config::default())?;
s.set(b"src", b"new")?;
s.set(b"dst", b"old")?;
assert!(!s.copy(b"src", b"dst", CopyMode::IfAbsent)?);
assert!(s.copy(b"src", b"dst", CopyMode::Replace)?);
assert_eq!(s.get(b"dst")?.as_deref(), Some(&b"new"[..]));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.
IfAbsent
Copy only when the destination does not exist (COPY without
REPLACE).
use kevy_embedded::{Config, CopyMode, Store};
let s = Store::open(Config::default())?;
s.set(b"src", b"v")?;
assert!(s.copy(b"src", b"fresh", CopyMode::IfAbsent)?, "an absent destination is written");
s.set(b"taken", b"old")?;
assert!(!s.copy(b"src", b"taken", CopyMode::IfAbsent)?);
assert_eq!(s.get(b"taken")?.as_deref(), Some(&b"old"[..]));Replace
Overwrite an existing destination (COPY … REPLACE).
use kevy_embedded::{Config, CopyMode, Store};
let s = Store::open(Config::default())?;
s.set(b"src", b"new")?;
s.set(b"dst", b"old")?;
assert!(s.copy(b"src", b"dst", CopyMode::Replace)?);
assert_eq!(s.get(b"dst")?.as_deref(), Some(&b"new"[..]));Trait Implementations§
impl Copy for CopyMode
impl Eq for CopyMode
impl StructuralPartialEq for CopyMode
Auto Trait Implementations§
impl Freeze for CopyMode
impl RefUnwindSafe for CopyMode
impl Send for CopyMode
impl Sync for CopyMode
impl Unpin for CopyMode
impl UnsafeUnpin for CopyMode
impl UnwindSafe for CopyMode
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