1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
use beserial::{Deserialize, Serialize}; bitflags! { #[derive(Serialize, Deserialize)] pub struct ServiceFlags: u32 { const NONE = 0b0000_0000; const NANO = 0b0000_0001; const LIGHT = 0b0000_0010; const FULL = 0b0000_0100; } } impl ServiceFlags { pub fn is_full_node(self) -> bool { self.contains(ServiceFlags::FULL) } pub fn is_light_node(self) -> bool { self.contains(ServiceFlags::LIGHT) } pub fn is_nano_node(self) -> bool { self.contains(ServiceFlags::NANO) } } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Services { pub provided: ServiceFlags, pub accepted: ServiceFlags, } impl Services { pub fn new(provided: ServiceFlags, accepted: ServiceFlags) -> Self { Services { provided, accepted } } pub fn full() -> Self { Services { provided: ServiceFlags::FULL, accepted: ServiceFlags::FULL, } } }