tf_demo_parser/demo/
mod.rs1use bitbuffer::{BitReadBuffer, BitReadStream, LittleEndian};
2
3pub mod data;
4pub mod gameevent_gen;
5pub mod gamevent;
6pub mod header;
7pub mod lzss;
8pub mod message;
9pub mod packet;
10pub mod parser;
11pub mod sendprop;
12mod sendprop_gen;
13pub mod vector;
14
15pub type Buffer<'a> = BitReadBuffer<'a, LittleEndian>;
16pub type Stream<'a> = BitReadStream<'a, LittleEndian>;
17
18pub struct Demo<'a> {
19 stream: Stream<'a>,
20}
21
22impl<'a> Demo<'a> {
23 pub fn new(bytes: &'a [u8]) -> Self {
24 let data = Buffer::new(bytes, LittleEndian);
25 let stream = Stream::new(data);
26 Demo { stream }
27 }
28
29 pub fn get_stream(&self) -> Stream<'a> {
31 self.stream.clone()
32 }
33}
34
35impl Demo<'static> {
36 pub fn owned(bytes: Vec<u8>) -> Self {
37 let data = Buffer::new_owned(bytes, LittleEndian);
38 let stream = Stream::new(data);
39 Demo { stream }
40 }
41}