byte_parser/
pit.rs

1
2use crate::position::Position;
3
4use std::fmt::Debug;
5
6pub trait PointInTime: Debug + Copy + Eq {
7
8	fn pos(&self) -> Position;
9
10	unsafe fn set_pos(&mut self, pos: Position);
11
12	#[inline]
13	fn record_pos(&self) -> Position {
14		self.pos()
15	}
16
17}
18
19/// Default PointInTime Implementation. 
20/// Used by Parser and StrParser
21#[derive(Debug, Clone, Copy, PartialEq, Eq)]
22pub struct ParserPointInTime {
23	pub(crate) pos: Position
24}
25
26impl ParserPointInTime {
27	pub(crate) fn new() -> Self {
28		Self {
29			pos: Position::null()
30		}
31	}
32}
33
34impl PointInTime for ParserPointInTime {
35	fn pos(&self) -> Position {
36		self.pos
37	}
38
39	unsafe fn set_pos(&mut self, pos: Position) {
40		self.pos = pos;
41	}
42}