mirror of
https://github.com/chatmail/core.git
synced 2026-05-02 21:06:31 +03:00
lazy_static: make it compile
This commit is contained in:
committed by
B. Petersen
parent
7d0dcfb3a5
commit
4fc6fa9c8a
@@ -22,7 +22,7 @@ pub enum ServerSocket {
|
|||||||
SSL = 2,
|
SSL = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct Server {
|
pub struct Server {
|
||||||
pub stype: u16,
|
pub stype: u16,
|
||||||
// more fields are needed, just to keep the example short
|
// more fields are needed, just to keep the example short
|
||||||
@@ -34,17 +34,18 @@ pub struct Provider {
|
|||||||
pub status: Status,
|
pub status: Status,
|
||||||
pub before_login_hint: &'static str,
|
pub before_login_hint: &'static str,
|
||||||
pub overview_page: &'static str,
|
pub overview_page: &'static str,
|
||||||
pub server: [Server], // this seems to be okay
|
pub server: Vec<Server>, // this seems to be okay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lazy_static::lazy_static! {
|
||||||
// TODO: the database will be auto-generated from the provider-db
|
// TODO: the database will be auto-generated from the provider-db
|
||||||
const DATABASE: [Provider; 1] = [
|
static ref DATABASE: Vec<Provider> = vec![
|
||||||
Provider {
|
Provider {
|
||||||
domains: "nauta.cu",
|
domains: "nauta.cu",
|
||||||
status: Status::OK,
|
status: Status::OK,
|
||||||
before_login_hint: "",
|
before_login_hint: "",
|
||||||
overview_page: "",
|
overview_page: "",
|
||||||
server: [Server; 2] = [Server { stype: 123 }, Server { stype: 456 }],
|
server: vec![Server { stype: 123 }, Server { stype: 456 }],
|
||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
Provider {
|
Provider {
|
||||||
@@ -68,6 +69,7 @@ const DATABASE: [Provider; 1] = [
|
|||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_provider_info(addr: &str) -> Option<&Provider> {
|
pub fn get_provider_info(addr: &str) -> Option<&Provider> {
|
||||||
let domain = match EmailAddress::new(addr) {
|
let domain = match EmailAddress::new(addr) {
|
||||||
@@ -76,7 +78,7 @@ pub fn get_provider_info(addr: &str) -> Option<&Provider> {
|
|||||||
}
|
}
|
||||||
.to_lowercase();
|
.to_lowercase();
|
||||||
|
|
||||||
for record in &DATABASE {
|
for record in DATABASE.iter() {
|
||||||
for record_domain in record.domains.split(' ') {
|
for record_domain in record.domains.split(' ') {
|
||||||
if record_domain == domain {
|
if record_domain == domain {
|
||||||
return Some(record);
|
return Some(record);
|
||||||
|
|||||||
Reference in New Issue
Block a user