tf_bindgen/codegen/
path.rs1use heck::ToUpperCamelCase;
2
3#[derive(Clone, Debug)]
5pub struct Path {
6 segments: Vec<String>,
7}
8
9impl Path {
10 pub fn empty() -> Self {
11 Self {
12 segments: Vec::new(),
13 }
14 }
15
16 pub fn new(segments: Vec<String>) -> Self {
17 Self { segments }
18 }
19
20 pub fn type_name(&self) -> String {
22 self.segments
23 .iter()
24 .map(|seg| seg.to_upper_camel_case())
25 .collect()
26 }
27
28 pub fn type_name_reduced(&self) -> String {
30 self.segments
31 .iter()
32 .skip(1)
33 .map(|seg| seg.to_upper_camel_case())
34 .collect()
35 }
36
37 pub fn segments(&self) -> impl Iterator<Item = &String> {
38 self.segments.iter()
39 }
40
41 pub fn push(&mut self, path: impl Into<String>) {
42 self.segments.push(path.into())
43 }
44}