Move nonce generator to utils module
This commit is contained in:
parent
185b012fc0
commit
332dbab413
|
@ -1,6 +1,6 @@
|
|||
use serde::Serialize;
|
||||
use uuid::Uuid;
|
||||
use super::Payload;
|
||||
use utils::nonce;
|
||||
|
||||
#[derive(Debug, Default, Serialize)]
|
||||
pub struct Command<T>
|
||||
|
@ -19,7 +19,7 @@ impl<T> Command<T>
|
|||
{
|
||||
Command {
|
||||
cmd: cmd.into(),
|
||||
nonce: Uuid::new_v4().to_string(),
|
||||
nonce: nonce(),
|
||||
args: args
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use uuid::Uuid;
|
||||
use super::Payload;
|
||||
use utils::nonce;
|
||||
|
||||
#[derive(Debug, Default, Serialize)]
|
||||
pub struct Handshake {
|
||||
|
@ -11,7 +11,7 @@ pub struct Handshake {
|
|||
impl Handshake {
|
||||
pub fn new(client_id: u64, version: u32) -> Self {
|
||||
Self {
|
||||
nonce: Uuid::new_v4().to_string(),
|
||||
nonce: nonce(),
|
||||
v: version,
|
||||
client_id: client_id.to_string()
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
use libc::getpid;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub fn pid() -> i32 {
|
||||
unsafe { getpid() as i32 }
|
||||
}
|
||||
|
||||
pub fn nonce() -> String {
|
||||
Uuid::new_v4().to_string()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue