helium_api/models/
oui.rs

1use serde::Deserialize;
2use std::fmt;
3
4#[derive(Clone, Deserialize, Debug)]
5/// Represents an OUI on the blockchain
6pub struct Oui {
7    /// The oui value.
8    pub oui: u64,
9    /// The base58 public key of the owner of the oui.
10    pub owner: String,
11    /// The current nonce for the oui
12    pub nonce: u64,
13    /// The base58 encoded public keys of the routers for this oui
14    pub addresses: Vec<String>,
15    /// The subnets for this oui
16    pub subnets: Vec<Subnet>,
17}
18
19/// Stats for ouis
20#[derive(Clone, Deserialize, Debug)]
21pub struct OuiStats {
22    pub count: u64,
23}
24
25#[derive(Clone, Deserialize, Debug)]
26/// An OUI owns a list of subnets, which are used to check if packets from a
27/// device with a given DevAddr need to be sent to the routers in the OUI
28pub struct Subnet {
29    base: u32,
30    mask: u32,
31}
32
33impl fmt::Display for Subnet {
34    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
35        f.write_fmt(format_args!("{}/{}", self.base, self.mask))
36    }
37}