1use humphrey_json::prelude::*;
2use std::fmt;
3
4#[derive(FromJson, IntoJson, Debug)]
6pub struct Snippet {
7 name: String,
8 description: String,
9 content: String,
10}
11
12impl fmt::Display for Snippet {
14 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
15 write!(f, "({}) - {}", self.name, self.description)
16 }
17}
18
19impl Snippet {
21 pub fn new(name: &str, description: &str, content: &str) -> Snippet {
22 Snippet {
23 name: name.to_string(),
24 description: description.to_string(),
25 content: content.to_string(),
26 }
27 }
28 pub fn get_name(&self) -> &str {
29 &self.name
30 }
31 pub fn set_name(&mut self, name: &str) {
32 self.name = name.to_string()
33 }
34 pub fn get_description(&self) -> &str {
35 &self.description
36 }
37 pub fn set_description(&mut self, description: &str) {
38 self.description = description.to_string()
39 }
40 pub fn get_content(&self) -> &str {
41 &self.content
42 }
43 pub fn set_content(&mut self, content: &str) {
44 self.content = content.to_string()
45 }
46}