diff options
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/germ/Cargo.toml | 2 | ||||
| -rw-r--r-- | crates/germ/src/ast/container.rs | 2 | ||||
| -rw-r--r-- | crates/germ/src/ast/node.rs | 2 | ||||
| -rw-r--r-- | crates/germ/src/convert.rs | 1 | ||||
| -rw-r--r-- | crates/germ/src/meta.rs | 4 | ||||
| -rw-r--r-- | crates/germ/src/request/response.rs | 3 | ||||
| -rw-r--r-- | crates/germ/src/request/status.rs | 6 | ||||
| -rw-r--r-- | crates/germ/src/request/verifier.rs | 2 |
8 files changed, 17 insertions, 5 deletions
diff --git a/crates/germ/Cargo.toml b/crates/germ/Cargo.toml index ad0eb96..a00114c 100644 --- a/crates/germ/Cargo.toml +++ b/crates/germ/Cargo.toml @@ -2,7 +2,7 @@ [package] name = "germ" -version = "0.3.5" +version = "0.3.6" authors = ["Fuwn <[email protected]>"] edition = "2021" description = "The Ultimate Gemini Toolkit." diff --git a/crates/germ/src/ast/container.rs b/crates/germ/src/ast/container.rs index e1a88a7..e97a092 100644 --- a/crates/germ/src/ast/container.rs +++ b/crates/germ/src/ast/container.rs @@ -25,9 +25,11 @@ use super::Node; /// ```rust /// let _ = germ::ast::Ast::from_string(r#"=> gemini://gem.rest/ GemRest"#); /// ``` +#[derive(Clone)] pub struct Ast { inner: Vec<Node>, } + impl Ast { /// Build an AST tree from Gemtext. /// diff --git a/crates/germ/src/ast/node.rs b/crates/germ/src/ast/node.rs index 04296ff..8fdeff6 100644 --- a/crates/germ/src/ast/node.rs +++ b/crates/germ/src/ast/node.rs @@ -26,7 +26,7 @@ /// - [Gemtext Documentation](https://gemini.circumlunar.space/docs/gemtext.gmi) /// - [Gemtext Cheatsheet](https://gemini.circumlunar.space/docs/cheatsheet.gmi). /// - [Gemini Specification](https://gemini.circumlunar.space/docs/specification.gmi). -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub enum Node { /// A text line /// diff --git a/crates/germ/src/convert.rs b/crates/germ/src/convert.rs index 2e323e1..4c5f0c8 100644 --- a/crates/germ/src/convert.rs +++ b/crates/germ/src/convert.rs @@ -27,6 +27,7 @@ mod markdown; mod macros; /// Different targets to convert Gemtext to +#[derive(Clone)] pub enum Target { /// Convert Gemtext to HTML HTML, diff --git a/crates/germ/src/meta.rs b/crates/germ/src/meta.rs index f8a9dfb..4ff7885 100644 --- a/crates/germ/src/meta.rs +++ b/crates/germ/src/meta.rs @@ -20,13 +20,14 @@ use std::collections::HashMap; /// Structure-ize a Gemini response's meta section into it's mime type and it's /// parameters. -#[derive(Debug, Default)] +#[derive(Debug, Default, Clone)] pub struct Meta { /// The mime type of a Gemini response mime: String, /// The parameters of a Gemini response parameters: HashMap<String, String>, } + impl ToString for Meta { /// Convert a `Meta` into a `String` /// @@ -58,6 +59,7 @@ impl ToString for Meta { }) } } + impl Meta { /// Create a new `Meta` /// diff --git a/crates/germ/src/request/response.rs b/crates/germ/src/request/response.rs index 5e1f436..efb0fde 100644 --- a/crates/germ/src/request/response.rs +++ b/crates/germ/src/request/response.rs @@ -20,7 +20,7 @@ use rustls::SupportedCipherSuite; use crate::request::Status; -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Response { status: Status, meta: String, @@ -28,6 +28,7 @@ pub struct Response { size: usize, suite: Option<SupportedCipherSuite>, } + impl Response { pub(super) fn new(data: &[u8], suite: Option<SupportedCipherSuite>) -> Self { let string_form = String::from_utf8_lossy(data).to_string(); diff --git a/crates/germ/src/request/status.rs b/crates/germ/src/request/status.rs index f46059a..793b0fc 100644 --- a/crates/germ/src/request/status.rs +++ b/crates/germ/src/request/status.rs @@ -28,7 +28,7 @@ use std::{fmt, fmt::Formatter}; /// assert_eq!(Status::from(10), Status::Input); /// assert_eq!(i32::from(Status::Input), 10); /// ``` -#[derive(Debug, PartialEq)] +#[derive(Debug, PartialEq, Clone)] pub enum Status { Input, SensitiveInput, @@ -50,9 +50,11 @@ pub enum Status { CertificateNotValid, Unsupported, } + impl Default for Status { fn default() -> Self { Self::Success } } + impl From<Status> for i32 { fn from(n: Status) -> Self { match n { @@ -78,6 +80,7 @@ impl From<Status> for i32 { } } } + impl From<i32> for Status { fn from(n: i32) -> Self { match n { @@ -103,6 +106,7 @@ impl From<i32> for Status { } } } + impl fmt::Display for Status { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { write!(f, "{:?}", self) diff --git a/crates/germ/src/request/verifier.rs b/crates/germ/src/request/verifier.rs index d6511c3..c1b763c 100644 --- a/crates/germ/src/request/verifier.rs +++ b/crates/germ/src/request/verifier.rs @@ -21,9 +21,11 @@ use std::time::SystemTime; use rustls::{client, client::ServerCertVerified, Certificate}; pub(super) struct GermVerifier; + impl GermVerifier { pub const fn new() -> Self { Self {} } } + impl client::ServerCertVerifier for GermVerifier { fn verify_server_cert( &self, |