pub fn peer_contents(
    name: &str,
    ip_str: &str,
    cidr_id: i64,
    is_admin: bool,
) -> Result<PeerContents, Error> {
    let public_key = KeyPair::generate().public;

    Ok(PeerContents {
        name: name.parse().map_err(|e: &str| anyhow!(e))?,
        ip: ip_str.parse()?,
        cidr_id,
        public_key: public_key.to_base64(),
        is_admin,
        endpoint: None,
        persistent_keepalive_interval: None,
        is_disabled: false,
        is_redeemed: true,
        invite_expires: None,
        candidates: vec![],
    })
}
//
// Below are helper functions for writing tests.
//
Below are helper functions for writing tests.
Below are helper functions for writing tests .
pub fn peer_contents(
    name: &str,
    ip_str: &str,
    cidr_id: i64,
    is_admin: bool,
) -> Result<PeerContents, Error> {
    let public_key = KeyPair::generate().public;
    Ok(PeerContents {
        name: name.parse().map_err(|e: &str| anyhow!(e))?,
        ip: ip_str.parse()?,
        cidr_id,
        public_key: public_key.to_base64(),
        is_admin,
        endpoint: None,
        persistent_keepalive_interval: None,
        is_disabled: false,
        is_redeemed: true,
        invite_expires: None,
        candidates: vec![],
    })
}
pub fn peer_contents ( name : & str , ip_str : & str , cidr_id : i64 , is_admin : bool , ) -> Result < PeerContents , Error > { let public_key = KeyPair :: generate ( ) . public ; Ok ( PeerContents { name : name . parse ( ) . map_err ( | e : & str | anyhow ! ( e ) ) ? , ip : ip_str . parse ( ) ? , cidr_id , public_key : public_key . to_base64 ( ) , is_admin , endpoint : None , persistent_keepalive_interval : None , is_disabled : false , is_redeemed : true , invite_expires : None , candidates : vec ! [ ] , } ) }
Below are helper functions for writing tests.
Below are helper functions for writing tests .
name
&str
ip_str
&str
cidr_id
i64
is_admin
bool