ntrip_client/
credentials.rs

1//! Client credentials
2use base64::{engine::general_purpose, Engine};
3
4#[cfg(doc)]
5use crate::NTRIPClient;
6
7/// [NTRIPCredentials] optionally used by [NTRIPClient]s
8#[derive(Clone, Default, PartialEq)]
9pub struct NTRIPCredentials {
10    user: String,
11    password: String,
12}
13
14impl NTRIPCredentials {
15    pub fn new(user: &str, password: &str) -> Self {
16        Self {
17            user: user.to_string(),
18            password: password.to_string(),
19        }
20    }
21
22    pub fn encode(&self) -> String {
23        general_purpose::STANDARD.encode(format!("{}:{}", self.user, self.password))
24    }
25}