1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
//! Syntactic position. /// Syntactic position. /// /// This contains not only byte-position, but also additional information such /// as node path and attribute index. /// /// This type is implemented based on FBX 7.4 data structure, and may change in /// future if FBX syntax has breaking changes. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SyntacticPosition { /// Byte position. pub(crate) byte_pos: u64, /// Beginning byte position of the node or attribute. pub(crate) component_byte_pos: u64, /// Node path. /// /// This is a vector of pairs of node indices in siblings (i.e. the number /// of preceding siblings) and node names. pub(crate) node_path: Vec<(usize, String)>, /// Node attribute index (if the position points an attribute). pub(crate) attribute_index: Option<usize>, } impl SyntacticPosition { /// Returns the byte position. pub fn byte_pos(&self) -> u64 { self.byte_pos } /// Beginning the byte position of the node or attribute. pub fn component_byte_pos(&self) -> u64 { self.component_byte_pos } /// Returns the node path. /// /// This is a vector of pairs of node indices in siblings (i.e. the number /// of preceding siblings) and node names. pub fn node_path(&self) -> &[(usize, String)] { &self.node_path } /// Node attribute index (if the position points an attribute). pub fn attribute_index(&self) -> Option<usize> { self.attribute_index } }