8 breaking releases

0.9.0 Jul 28, 2024
0.8.0 Jul 23, 2023
0.7.0 Jan 16, 2023
0.6.0 Sep 1, 2022
0.1.0 Dec 26, 2019

#411 in Parser implementations

Download history 1/week @ 2024-06-16 5/week @ 2024-06-23 1/week @ 2024-06-30 41/week @ 2024-07-07 3/week @ 2024-07-14 57/week @ 2024-07-21 251/week @ 2024-07-28 19/week @ 2024-08-04 2/week @ 2024-08-11 1/week @ 2024-08-25 5/week @ 2024-09-01 4/week @ 2024-09-08 14/week @ 2024-09-15 44/week @ 2024-09-22 26/week @ 2024-09-29

88 downloads per month
Used in 2 crates

MIT/Apache

210KB
3.5K SLoC

Rust 2.5K SLoC // 0.0% comments C++ 877 SLoC // 0.0% comments Shell 16 SLoC // 0.1% comments Pan 11 SLoC // 0.2% comments

hltas

crates.io Documentation

CHANGELOG

A crate for reading and writing Half-Life TAS scripts (.hltas).

Examples

use hltas::{HLTAS, types::{JumpBug, Line, Times}};

let contents = "\
version 1
demo test
frames
------b---|------|------|0.001|-|-|5";

match HLTAS::from_str(&contents) {
    Ok(hltas) => {
        assert_eq!(hltas.properties.demo.as_deref(), Some("test"));

        if let Line::FrameBulk(frame_bulk) = &hltas.lines[0] {
            assert_eq!(
                frame_bulk.auto_actions.jump_bug,
                Some(JumpBug { times: Times::UnlimitedWithinFrameBulk })
            );
            assert_eq!(&frame_bulk.frame_time, "0.001");
            assert_eq!(frame_bulk.frame_count.get(), 5);
        } else {
            unreachable!()
        }
    }

    // The errors are pretty-printed with context.
    Err(error) => println!("{}", error),
}

Features

  • serde1: implements serde's Serialize and Deserialize traits for all types.

  • proptest1: implements proptest's Arbitrary trait for all types. Only "valid" contents are generated, as in, writing to string and parsing back will work and give you the same result.

C++ Wrapper

Also included is a C++ wrapper, exporting the same C++ interface as the previous C++ version of HLTAS.

Using the C++ wrapper from CMake

  • You will need Rust: either from your distribution's packages, or from rustup.
  • From your project's CMakeLists.txt, call add_subdirectory("path/to/hltas").
  • Link to the hltas-cpp target: target_link_libraries(your-target hltas-cpp).

License: MIT/Apache-2.0

Dependencies

~0.9–1.8MB
~33K SLoC