diff --git a/src/connection/builder.rs b/src/connection/builder.rs index ca7b760..5720f0f 100644 --- a/src/connection/builder.rs +++ b/src/connection/builder.rs @@ -1,4 +1,4 @@ -use super::{Verifier, FingerPrintStore}; +use super::{FingerPrintStore, Verifier}; use rustls::ServerConfig; use std::{net::TcpStream, sync::Arc}; diff --git a/src/connection/mod.rs b/src/connection/mod.rs index ea8b4f0..453f05e 100644 --- a/src/connection/mod.rs +++ b/src/connection/mod.rs @@ -2,7 +2,11 @@ pub mod builder; pub mod error; pub mod verifier; -pub use self::{builder::Builder, error::Error, verifier::{FingerPrintStore, Verifier}}; +pub use self::{ + builder::Builder, + error::Error, + verifier::{FingerPrintStore, Verifier}, +}; #[derive(Debug)] pub struct Connection { diff --git a/src/connection/verifier.rs b/src/connection/verifier.rs index c98bbc8..745916b 100644 --- a/src/connection/verifier.rs +++ b/src/connection/verifier.rs @@ -1,6 +1,6 @@ use rustls::server::ClientCertVerifier; -use crate::{prelude::CertificateStore, mailuser::Mailuser}; +use crate::{mailuser::Mailuser, prelude::CertificateStore}; use std::sync::Mutex; #[derive(Debug)] @@ -20,11 +20,11 @@ impl ClientCertVerifier for Verifier { } fn verify_client_cert( - &self, - end_entity: &rustls::Certificate, - intermediates: &[rustls::Certificate], - now: std::time::SystemTime, - ) -> Result { + &self, + end_entity: &rustls::Certificate, + intermediates: &[rustls::Certificate], + now: std::time::SystemTime, + ) -> Result { todo!() } } diff --git a/src/message/mod.rs b/src/message/mod.rs index 1c64aba..4b16693 100644 --- a/src/message/mod.rs +++ b/src/message/mod.rs @@ -7,7 +7,11 @@ use serde::{Deserialize, Serialize}; mod error; mod link; mod parser; -pub use {error::Error, link::Link, parser::{GemtextNode, Parser}}; +pub use { + error::Error, + link::Link, + parser::{GemtextNode, Parser}, +}; #[derive(Clone, Debug, PartialEq)] pub struct Recipients { diff --git a/src/message/parser.rs b/src/message/parser.rs index dd0544a..1a3ba0f 100644 --- a/src/message/parser.rs +++ b/src/message/parser.rs @@ -1,6 +1,6 @@ -use std::fmt; -use crate::prelude::Mailbox; use super::{Link, Recipients}; +use crate::prelude::Mailbox; +use std::fmt; #[derive(Debug)] pub struct PreBlk<'a> { @@ -121,7 +121,7 @@ impl<'a> Parser<'a> { Self { state: State::Normal, title: None, - lines: vec![] + lines: vec![], } } @@ -145,7 +145,7 @@ impl<'a> Parser<'a> { if self.title.is_none() { match &line { GemtextNode::Heading1(t) => self.title = Some(t.clone()), - _ => {}, + _ => {} } } self.lines.push(line); @@ -172,6 +172,17 @@ impl<'a> Parser<'a> { self.state = State::Preformatted(preblk); } + fn leave_preformatted(&mut self) { + match &self.state { + State::Preformatted(v) => { + let s = v.lines.join("\n").to_string(); + self.lines.push(GemtextNode::Text(s)); + self.state = State::Normal; + } + _ => panic!("Attempted to leave preformatted mode when not in preformatted mode"), + } + } + fn senders(&mut self, line: &'a str) { self.lines.push(GemtextNode::parse_senders(line)); } @@ -190,16 +201,22 @@ impl<'a> Parser<'a> { s if s.starts_with('<') => self.senders(s), s if s.starts_with(':') => self.recipients(s), s if s.starts_with('@') => {}, - s => {}, + s => self.lines.push(GemtextNode::Text(s.to_string())), } } fn parse_preformatted(&mut self, line: &'a str) { - todo!() + if line.starts_with("```") { + self.leave_preformatted(); + } else { + match &mut self.state { + State::Preformatted(p) => p.lines.push(line), + _ => panic!("Attempt to parse as preformatted when not in preformatted mode"), + } + } } fn parse_quote(&mut self, line: &'a str) { todo!() } } -