File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change 1
- //! The official Rust implementation of the RANDEVU algorithm
1
+ //! The official Rust implementation of the [RANDEVU](https://github.com/TypicalHog/randevu) algorithm
2
+ //!
3
+ //! # Example
4
+ //! ```rust
5
+ //! use randevu::{rdv, utc_date_with_offset};
6
+ //!
7
+ //! fn main() {
8
+ //! let object = "THE_SIMPSONS";
9
+ //! let date = utc_date_with_offset(0);
10
+ //! let rdv = rdv(object, &date);
11
+ //!
12
+ //! println!("Object {} has RDV{} today", object, rdv);
13
+ //! }
14
+ //! ```
2
15
3
16
use blake3;
4
17
use chrono:: { Duration , Utc } ;
5
18
6
- /// Returns current UTC date ( String) in ISO 8601 format, with an offset ( i64) in days
19
+ /// Returns current UTC DATE ` String` in ISO 8601 format (YYYY-MM-DD) , with an OFFSET ` i64` in days
7
20
pub fn utc_date_with_offset ( offset : i64 ) -> String {
8
21
( Utc :: now ( ) + Duration :: days ( offset) )
9
22
. format ( "%Y-%m-%d" )
10
23
. to_string ( )
11
24
}
12
25
13
- /// Returns RDV level ( u32) for an object ( &str) on a specific date ( &str)
26
+ /// Returns RDV level ` u32` for an OBJECT ` &str` on a specific DATE ` &str`
14
27
///
15
- /// RDV = number of leading zero bits in blake3(blake3(OBJECT) || blake3(DATE))
28
+ /// ** RDV = number of leading zero bits in blake3(blake3(OBJECT) || blake3(DATE))**
16
29
pub fn rdv ( object : & str , date : & str ) -> u32 {
17
30
let mut hasher = blake3:: Hasher :: new ( ) ;
18
31
hasher. update ( blake3:: hash ( object. as_bytes ( ) ) . as_bytes ( ) ) ;
You can’t perform that action at this time.
0 commit comments