dtypes/redis/
mod.rs

1//! # Redis Types
2//!
3//! This crate provides a set of types that can be stored in Redis. The types are:
4//!
5//! * [bool](redis::Dbool)
6//! * Integer types:
7//!     * signed Integer: [i8](redis::Di8), [i16](redis::Di16), [i32](redis::Di32), [i64](redis::Di64), [isize](redis::Disize)
8//!     * unsigned Integer: [u8](redis::Du8), [u16](redis::Du16), [u32](redis::Du32), [u64](redis::Du64), [usize](redis::Dusize)
9//! * [String](redis::DString)
10//! * [List](redis::List)
11//! * Sync types:
12//!     * [Mutex](redis::Mutex)
13//!     * [ClockOrdered](redis::ClockOrdered)
14//!
15//! This crate implements the most common traits for the primitive types, so it is frictionless to use them in place.
16//! The methods of the types can be seen in the documentation of [Generic](redis::Generic).
17//! With this crate it is possible to create multiple services that shares the values via Redis.
18//! This is helpful if you want to create a distributed system and run multiple instances of the same service.
19//! Or you want to communicate between different services. All this kind of stuff can be done with this crate.
20//!
21//! # Upcoming Features
22//!
23//! It will be possible to create happens-before relationships between store and load operations like atomic types.
24//! Also it will be possible to create other backends than Redis.
25//!
26//! # Usage
27//!
28//! ```
29//! use dtypes::redis::types::Di32 as i32;
30//!
31//! let client = redis::Client::open("redis://localhost:6379").unwrap();
32//! let mut i32 = i32::with_value(1, "test_add", client.clone());
33//!
34//! i32 = i32 + i32::with_value(2, "test_add2", client.clone());
35//! assert_eq!(i32, 3);
36//! ```
37//!
38//! More examples can be found on the doc pages of the types.
39//!
40//! # Custom Types
41//!
42//! It is possible to implement your own complex types by implementing the [BackedType](crate::BackedType) trait.
43//! But it should not be needed as long as your type implements some or all of the various [Ops](https://doc.rust-lang.org/std/ops/index.html) traits.
44mod barrier;
45mod bool_type;
46mod clock;
47mod generic;
48mod helper;
49mod integer;
50mod list;
51mod mutex;
52mod rwlock;
53mod string;
54
55pub(crate) use helper::apply_operator;
56
57pub mod sync {
58    pub use crate::redis::barrier::{Barrier, BarrierWaitResult};
59    pub use crate::redis::clock::ClockOrdered;
60    pub use crate::redis::mutex::{Guard, LockError, Mutex};
61    pub use crate::redis::rwlock::{RwLock, RwLockReadGuard, RwLockWriteGuard};
62}
63
64/// Holds all the types that can be stored in Redis.
65pub mod types {
66    pub use crate::redis::bool_type::TBool as Dbool;
67    pub use crate::redis::generic::Generic;
68    pub use crate::redis::integer::{
69        Ti16 as Di16, Ti32 as Di32, Ti64 as Di64, Ti8 as Di8, Tisize as Disize, Tu16 as Du16,
70        Tu32 as Du32, Tu64 as Du64, Tu8 as Du8, Tusize as Dusize,
71    };
72    pub use crate::redis::list::{List, ListCache, ListIter};
73    pub use crate::redis::string::TString as DString;
74}