Skip to content
Snippets Groups Projects
contact.rs 1.22 KiB
Newer Older
Stephen D's avatar
Stephen D committed
use heapless::{String, Vec};

Stephen D's avatar
Stephen D committed
pub const MAX_CONTACTS: usize = 20;
Stephen D's avatar
Stephen D committed
pub const MAX_CONTACT_NAME_LENGTH: usize = 20;
pub const MAX_CONTACT_CALLSIGN_LENGTH: usize = 10;
Stephen D's avatar
Stephen D committed

Stephen D's avatar
Stephen D committed
#[derive(Debug, Clone)]
pub struct Contact {
Stephen D's avatar
Stephen D committed
    pub callsign: String<MAX_CONTACT_CALLSIGN_LENGTH>,
Stephen D's avatar
Stephen D committed
    pub ssid: u8,
Stephen D's avatar
Stephen D committed
    pub name: String<MAX_CONTACT_NAME_LENGTH>,
Stephen D's avatar
Stephen D committed
}

#[derive(Debug)]
pub struct ContactGroup {
Stephen D's avatar
Stephen D committed
    pub contacts: Vec<Contact, MAX_CONTACTS>,
Stephen D's avatar
Stephen D committed
}

impl Default for ContactGroup {
    fn default() -> Self {
        let mut contacts = Vec::new();
        contacts
            .push(Contact {
                callsign: String::try_from("VA3QAK").unwrap(),
                ssid: 19,
                name: String::try_from("Adrian").unwrap(),
            })
            .unwrap();
        contacts
            .push(Contact {
                callsign: String::try_from("VE3SVF").unwrap(),
                ssid: 239,
                name: String::try_from("Sasha").unwrap(),
            })
            .unwrap();
        contacts
            .push(Contact {
                callsign: String::try_from("VE3KCN").unwrap(),
                ssid: 19,
                name: String::try_from("Cam").unwrap(),
            })
            .unwrap();

        Self { contacts }
    }
}