asai 0.1.2

Library for .ass file parsing.
Documentation
  • Coverage
  • 2.13%
    2 out of 94 items documented0 out of 41 items with examples
  • Size
  • Source code size: 37.87 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 9.81 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Nikit4v/asai
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Nikit4v

asai

A rust library for parsing .ass files, which are used for storing subtitles in the Advanced SubStation Alpha format.

Installation

Add this to your Cargo.toml:

[dependencies]
asai = "0.1.0"

Usage

If you want to simply parse ass, you can use parse_str from asai's root:

use asai::structure::Ass;

fn main() {
    let data = "...";
    let ass = asai::parse_str(data);
    println!("{:?}", ass.styles); // Get styles
    println!("{:?}", ass.info); // Get info
    println!("{:?}", ass.events); // Get events
}

Another approach is to use custom structure to represent ass. It allows us to set defaults and parse only required fields. There is an example:

use asai_macro::FromLine;
use asai::structure::event::EventKey;
use asai::structure::Ass;

#[derive(FromLine, Debug)]
struct MyEvent<'a> {
    #[name("Text")]
    text: &'a str,
    #[name("Custom")]
    #[default("Some default value")]
    custom_field: &'a str
}

fn main() {
    let data = "...";
    let my_events: FormattedSection<EventKey, MyEvent> = Ass::parse_section("Events", data).unwrap();
}