pub struct EventBuilder<'a> { /* private fields */ }Expand description
Builder for creating ASS events with fluent API
Provides an ergonomic way to construct ASS events with method chaining. Supports all event types and automatically handles format validation.
§Examples
use ass_editor::{EventBuilder, EditorDocument};
let mut doc = EditorDocument::new();
// Create a dialogue event
let event_line = EventBuilder::dialogue()
.start_time("0:00:00.00")
.end_time("0:00:05.00")
.style("Default")
.speaker("Character")
.text("Hello, world!")
.layer(0)
.build()
.unwrap();
// Add to document
doc.add_event_line(&event_line).unwrap();Implementations§
Source§impl<'a> EventBuilder<'a>
impl<'a> EventBuilder<'a>
Sourcepub fn start_time<S: Into<Cow<'a, str>>>(self, time: S) -> Self
pub fn start_time<S: Into<Cow<'a, str>>>(self, time: S) -> Self
Set start time (e.g., “0:00:05.00”)
Sourcepub fn end_time<S: Into<Cow<'a, str>>>(self, time: S) -> Self
pub fn end_time<S: Into<Cow<'a, str>>>(self, time: S) -> Self
Set end time (e.g., “0:00:10.00”)
Sourcepub fn margin_left(self, margin: u32) -> Self
pub fn margin_left(self, margin: u32) -> Self
Set left margin
Sourcepub fn margin_right(self, margin: u32) -> Self
pub fn margin_right(self, margin: u32) -> Self
Set right margin
Sourcepub fn margin_vertical(self, margin: u32) -> Self
pub fn margin_vertical(self, margin: u32) -> Self
Set vertical margin
Sourcepub fn margin_top(self, margin: u32) -> Self
pub fn margin_top(self, margin: u32) -> Self
Set top margin (V4++)
Sourcepub fn margin_bottom(self, margin: u32) -> Self
pub fn margin_bottom(self, margin: u32) -> Self
Set bottom margin (V4++)
Sourcepub fn build_with_version(self, version: ScriptVersion) -> Result<String>
pub fn build_with_version(self, version: ScriptVersion) -> Result<String>
Build the event with a specific format version
Sourcepub fn build_with_format(&self, format: &[&str]) -> Result<String>
pub fn build_with_format(&self, format: &[&str]) -> Result<String>
Build the event with a specific format line The format parameter should contain field names like [“Layer”, “Start”, “End”, “Style”, “Text”]
Trait Implementations§
Source§impl<'a> Debug for EventBuilder<'a>
impl<'a> Debug for EventBuilder<'a>
Source§impl<'a> Default for EventBuilder<'a>
impl<'a> Default for EventBuilder<'a>
Source§fn default() -> EventBuilder<'a>
fn default() -> EventBuilder<'a>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<'a> Freeze for EventBuilder<'a>
impl<'a> RefUnwindSafe for EventBuilder<'a>
impl<'a> Send for EventBuilder<'a>
impl<'a> Sync for EventBuilder<'a>
impl<'a> Unpin for EventBuilder<'a>
impl<'a> UnwindSafe for EventBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more