diff options
| author | Fuwn <[email protected]> | 2022-06-10 03:02:16 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2022-06-10 03:02:16 +0000 |
| commit | ff518622bfed876d92cad857df09591e9f2a89c8 (patch) | |
| tree | b5fe728cb0fe884dbcafc89c8fb8eea5c20cfc4f /src | |
| parent | feat(meta): impl ToString for Meta (diff) | |
| download | germ-ff518622bfed876d92cad857df09591e9f2a89c8.tar.xz germ-ff518622bfed876d92cad857df09591e9f2a89c8.zip | |
feat(meta): mutable access to meta for construction
Diffstat (limited to 'src')
| -rw-r--r-- | src/meta.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/meta.rs b/src/meta.rs index 3973d3b..2aaa543 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -20,7 +20,7 @@ use std::collections::HashMap; /// Structure-ize a Gemini response's meta section into it's mime type and it's /// parameters. -#[derive(Debug)] +#[derive(Debug, Default)] pub struct Meta { /// The mime type of a Gemini response mime: String, @@ -48,6 +48,9 @@ impl ToString for Meta { } impl Meta { #[must_use] + pub fn new() -> Self { Self::default() } + + #[must_use] pub fn from_string(meta: &str) -> Self { let mut metas = meta.split(';'); let mime = metas.next().unwrap_or("").to_string(); @@ -73,8 +76,14 @@ impl Meta { #[must_use] pub fn mime(&self) -> &str { &self.mime } + pub fn mime_mut(&mut self) -> &mut String { &mut self.mime } + #[must_use] pub const fn parameters(&self) -> &HashMap<String, String> { &self.parameters } + + pub fn parameters_mut(&mut self) -> &mut HashMap<String, String> { + &mut self.parameters + } } |