Code reformatting.
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
use crate::event::Event;
|
||||
use crate::simplebus::Bus;
|
||||
use std::sync::Mutex;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::event::Event;
|
||||
use crate::simplebus::Bus;
|
||||
|
||||
lazy_static! {
|
||||
static ref STATIC_BUS: Mutex<Bus<Event>> = Mutex::new(Bus::new());
|
||||
}
|
||||
|
||||
pub fn register<F>(closure: F) -> Uuid where F: FnMut(&Uuid, Event) -> bool + Send + Sync + 'static {
|
||||
pub fn register<F>(closure: F) -> Uuid
|
||||
where F: FnMut(&Uuid, Event) -> bool + Send + Sync + 'static {
|
||||
STATIC_BUS.lock().unwrap().register(Box::new(closure))
|
||||
}
|
||||
|
||||
|
||||
+4
-5
@@ -1,17 +1,16 @@
|
||||
use std::net::IpAddr;
|
||||
use std::num;
|
||||
|
||||
pub use constants::*;
|
||||
use rand::Rng;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use thread_priority::*;
|
||||
|
||||
pub use constants::*;
|
||||
|
||||
use crate::dns::protocol::DnsRecord;
|
||||
|
||||
pub mod constants;
|
||||
pub mod simplebus;
|
||||
pub mod eventbus;
|
||||
pub mod simplebus;
|
||||
|
||||
/// Convert bytes array to HEX format
|
||||
pub fn to_hex(buf: &[u8]) -> String {
|
||||
@@ -120,14 +119,14 @@ pub fn is_yggdrasil(addr: &IpAddr) -> bool {
|
||||
pub fn is_yggdrasil_record(record: &DnsRecord) -> bool {
|
||||
match record {
|
||||
DnsRecord::UNKNOWN { .. } => {}
|
||||
DnsRecord::A { .. } => { return false }
|
||||
DnsRecord::A { .. } => return false,
|
||||
DnsRecord::NS { .. } => {}
|
||||
DnsRecord::CNAME { .. } => {}
|
||||
DnsRecord::SOA { .. } => {}
|
||||
DnsRecord::PTR { .. } => {}
|
||||
DnsRecord::MX { .. } => {}
|
||||
DnsRecord::TXT { .. } => {}
|
||||
DnsRecord::AAAA { addr, .. } => { return is_yggdrasil(&IpAddr::from(*addr))}
|
||||
DnsRecord::AAAA { addr, .. } => return is_yggdrasil(&IpAddr::from(*addr)),
|
||||
DnsRecord::SRV { .. } => {}
|
||||
DnsRecord::OPT { .. } => {}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use uuid::Uuid;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct Bus<T> {
|
||||
listeners: HashMap<Uuid, Box<dyn FnMut(&Uuid, T) -> bool + Send + Sync>>
|
||||
}
|
||||
@@ -33,8 +34,8 @@ mod tests {
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::Bus;
|
||||
use crate::event::Event;
|
||||
use crate::Bus;
|
||||
|
||||
#[test]
|
||||
fn test1() {
|
||||
|
||||
Reference in New Issue
Block a user