Debian Codegraph @

src/state_tracker/token.rs

raw symbols SCIP
1 /// A raw bencode token
2 #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Debug)]
3 pub enum Token<'a> {
4 /// The beginning of a list
5 List,
6 /// The beginning of a dictionary
7 Dict,
8 /// A byte string; may not be UTF-8
9 String(&'a [u8]),
10 /// A number; we explicitly *don't* parse it here, as it could be signed, unsigned, or a bignum
11 Num(&'a str),
12 /// The end of a list or dictionary
13 End,
14 }
15
16 impl<'a> Token<'a> {
17 pub fn name(&self) -> &'static str {
18 match *self {
19 Token::Dict => "Dict",
20 Token::End => "End",
21 Token::List => "List",
22 Token::Num(_) => "Num",
23 Token::String(_) => "String",
24 }
25 }
26 }