Debian Codegraph @

src/node/blob.rs

raw symbols SCIP
1 use std::collections::hash_map::DefaultHasher;
2 use std::fmt;
3 use std::hash::Hash;
4
5 use crate::node::Node;
6
7 /// A blob node.
8 #[derive(Clone, Debug)]
9 pub struct Blob {
10 content: String,
11 }
12
13 impl Blob {
14 /// Create a node.
15 #[inline]
16 pub fn new<T>(content: T) -> Self
17 where
18 T: Into<String>,
19 {
20 Blob {
21 content: content.into(),
22 }
23 }
24 }
25
26 impl fmt::Display for Blob {
27 #[inline]
28 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
29 self.content.fmt(formatter)
30 }
31 }
32
33 impl Node for Blob {
34 #[inline]
35 fn get_name(&self) -> &str {
36 "blob"
37 }
38 }
39
40 impl super::NodeDefaultHash for Blob {
41 #[inline]
42 fn default_hash(&self, state: &mut DefaultHasher) {
43 self.content.hash(state);
44 }
45 }