make JID struct etc. public

This commit is contained in:
cel 🌸 2023-06-16 14:48:19 +01:00
parent 9cdf4953fe
commit e9c742f4a9
Signed by: cel
GPG Key ID: 48E29AF13B5F1349
1 changed files with 10 additions and 6 deletions

View File

@ -1,21 +1,25 @@
use std::str::FromStr; use std::str::FromStr;
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug)]
struct JID { pub struct JID {
// TODO: validate localpart (length, char] // TODO: validate localpart (length, char]
localpart: Option<String>, pub localpart: Option<String>,
domainpart: String, pub domainpart: String,
resourcepart: Option<String>, pub resourcepart: Option<String>,
} }
#[derive(Debug)] #[derive(Debug)]
enum JIDParseError { pub enum JIDParseError {
Empty, Empty,
Malformed, Malformed,
} }
impl JID { impl JID {
fn new(localpart: Option<String>, domainpart: String, resourcepart: Option<String>) -> Self { pub fn new(
localpart: Option<String>,
domainpart: String,
resourcepart: Option<String>,
) -> Self {
Self { Self {
localpart, localpart,
domainpart: domainpart.parse().unwrap(), domainpart: domainpart.parse().unwrap(),