Crate micro_types
source ·Expand description
Redis Types
This crate provides a set of types that can be stored in Redis. The types are:
This crate implements the most common traits for the primitive types, so it is frictionless to use them in place. With this crate it is possible to create multiple services that shares the values via Redis. This is helpful if you want to create a distributed system and run multiple instances of the same service. Or you want to communicate between different services. All this kind of stuff can be done with this crate.
Upcoming Features
In a later release it will be possible to lock values like a Mutex or RwLock. Also it will be possible to create happens-before relationships between store and load operations like atomic types. So it will be possible to use the types in a concurrent environment in the same way as in a distributed one.
Also it will be possible to create other backends than Redis.
Usage
use types::i32;
use types::BackedType;
let client = redis::Client::open("redis://localhost:6379").unwrap();
let mut i32 = i32::new(1, client.clone(), "test_add".to_string());
i32 = i32 + i32::new(2, client, "test_add2".to_string());
assert_eq!(i32, 3);Custom Types
It is possible to implement your own complex types by implementing the BackedType trait. But it should not be needed as long as your type implements some or all of the various Ops traits.
Structs
Traits
- The BackedType trait is used to define the methods that are common to all types.