Skip to content

Commit

Permalink
doc adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Heiss committed Oct 29, 2023
1 parent f8139ed commit ad2315b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/redis/generic.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! This module contains the generic type.
//! The generic type is used to implement the common methods for all types.
//! The generic type is not meant to be used directly.
//!
//!
use crate::redis::apply_operator;
use redis::{Commands, RedisResult};
use serde::{de::DeserializeOwned, Serialize};
use std::fmt::{Debug, Display};
use std::ops;

/// The generic type is used to implement the common methods for all types.
///
/// The generic type is not meant to be used directly. Instead use one of the aliases.
///
/// Mostly you will interact with the methods [Generic::store], [Generic::acquire] and [Generic::into_inner].
pub struct Generic<T> {
pub(crate) cache: Option<T>,
pub(crate) key: String,
Expand Down Expand Up @@ -78,7 +78,7 @@ where
new_type
}

/// The set method sets the value of the type.
/// The store method sets the value of the type.
pub fn store(&mut self, value: T) {
let value = self.set(value);
self.cache = Some(value);
Expand Down Expand Up @@ -106,7 +106,7 @@ where
res.expect("Failed to set value");
}

/// The get method returns a reference to the value stored in the type.
/// The acquire method returns a reference to the value stored in the type.
/// Loads it from the redis directly.
///
/// # Example
Expand Down
1 change: 1 addition & 0 deletions src/redis/list.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::redis::Generic;
use serde::de::DeserializeOwned;
use serde::Serialize;
use std::collections::VecDeque;
Expand Down
23 changes: 11 additions & 12 deletions src/redis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,25 @@
//!
//! This crate provides a set of types that can be stored in Redis. The types are:
//!
//! * [bool](crate::Dbool)
//! * [bool](redis::Dbool)
//! * Integer types:
//! * signed Integer: [i8](crate::redis::Di8), [i16](crate::redis::Di16), [i32](crate::redis::Di32), [i64](crate::redis::Di64), [isize](crate::redis::Disize)
//! * unsigned Integer: [u8](crate::redis::Du8), [u16](crate::redis::Du16), [u32](crate::redis::Du32), [u64](crate::redis::Du64), [usize](crate::redis::Dusize)
//! * [String](crate::redis::DString)
//! * signed Integer: [i8](redis::Di8), [i16](redis::Di16), [i32](redis::Di32), [i64](redis::Di64), [isize](redis::Disize)
//! * unsigned Integer: [u8](redis::Du8), [u16](redis::Du16), [u32](redis::Du32), [u64](redis::Du64), [usize](redis::Dusize)
//! * [String](redis::DString)
//! * [List](redis::List)
//! * Sync types:
//! * [Mutex](redis::Mutex)
//! * [SetLoad](redis::SetLoad)
//!
//! This crate implements the most common traits for the primitive types, so it is frictionless to use them in place.
//! The methods of the types can be seen in the documentation of [Generic](redis::Generic).
//! 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.
//! It will be possible to create happens-before relationships between store and load operations like atomic types.
//!
//! # Usage
//!
Expand All @@ -33,10 +34,8 @@
//! assert_eq!(i32, 3);
//! ```
//!
//! # Custom Types
//! More examples can be found on the doc pages of the types.
//!
//! It is possible to implement your own complex types by implementing the [BackedType](crate::BackedType) trait.
//! 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.
mod bool_type;
mod generic;
mod helper;
Expand Down
1 change: 1 addition & 0 deletions src/redis/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ end
return nil"#;

/// The RedisMutex struct.
///
/// It is used to lock a value in Redis, so that only one instance can access it at a time.
/// You have to use RedisGeneric as the data type.
/// It is a wrapper around the data type you want to store like the Mutex in std.
Expand Down
1 change: 1 addition & 0 deletions src/redis/set_load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ return {redis.call("GET", key), redis.call("GET", key .. ":order")}
"#;

/// The SetLoad type.
///
/// It is used to store a value in redis and load it in sync.
/// It tracks automatically an ordering number to ensure that the value is only stored if the order is greater than the current order, mostly from other instances.
/// The value is only stored if the order is greater than the current order.
Expand Down

0 comments on commit ad2315b

Please sign in to comment.