pub struct Style<'a> {Show 28 fields
pub name: &'a str,
pub parent: Option<&'a str>,
pub fontname: &'a str,
pub fontsize: &'a str,
pub primary_colour: &'a str,
pub secondary_colour: &'a str,
pub outline_colour: &'a str,
pub back_colour: &'a str,
pub bold: &'a str,
pub italic: &'a str,
pub underline: &'a str,
pub strikeout: &'a str,
pub scale_x: &'a str,
pub scale_y: &'a str,
pub spacing: &'a str,
pub angle: &'a str,
pub border_style: &'a str,
pub outline: &'a str,
pub shadow: &'a str,
pub alignment: &'a str,
pub margin_l: &'a str,
pub margin_r: &'a str,
pub margin_v: &'a str,
pub margin_t: Option<&'a str>,
pub margin_b: Option<&'a str>,
pub encoding: &'a str,
pub relative_to: Option<&'a str>,
pub span: Span,
}Expand description
Re-export commonly used types from ass-core Style definition from [V4+ Styles] section
Represents a single style definition that can be referenced by events. All fields are stored as zero-copy string references to the original source text for maximum memory efficiency.
§Examples
use ass_core::parser::ast::Style;
let style = Style {
name: "Default",
fontname: "Arial",
fontsize: "20",
..Style::default()
};
assert_eq!(style.name, "Default");
assert_eq!(style.fontname, "Arial");Fields§
§name: &'a strStyle name (must be unique within script)
parent: Option<&'a str>Parent style name for inheritance (None if no inheritance)
fontname: &'a strFont name for text rendering
fontsize: &'a strFont size in points
primary_colour: &'a strPrimary color in BGR format (&HBBGGRR)
secondary_colour: &'a strSecondary color for collision effects
outline_colour: &'a strOutline color
back_colour: &'a strShadow/background color
bold: &'a strBold flag (-1/0 or weight)
italic: &'a strItalic flag (0/1)
underline: &'a strUnderline flag (0/1)
strikeout: &'a strStrikeout flag (0/1)
scale_x: &'a strHorizontal scale percentage
scale_y: &'a strVertical scale percentage
spacing: &'a strCharacter spacing in pixels
angle: &'a strRotation angle in degrees
border_style: &'a strBorder style (1=outline+shadow, 3=opaque box)
outline: &'a strOutline width in pixels
shadow: &'a strShadow depth in pixels
alignment: &'a strAlignment (1-3 + 4/8 for vertical positioning)
margin_l: &'a strLeft margin in pixels
margin_r: &'a strRight margin in pixels
margin_v: &'a strVertical margin in pixels (V4+)
margin_t: Option<&'a str>Top margin in pixels (V4++)
margin_b: Option<&'a str>Bottom margin in pixels (V4++)
encoding: &'a strFont encoding identifier
relative_to: Option<&'a str>Positioning context (V4++)
span: SpanSpan in source text where this style is defined
Implementations§
Source§impl Style<'_>
impl Style<'_>
Sourcepub fn to_ass_string(&self) -> String
pub fn to_ass_string(&self) -> String
Convert style to ASS string representation
Generates the standard ASS style line format for V4+ styles.
Uses margin_v by default, but will use margin_t/margin_b if provided (V4++ format).
§Examples
let style = Style {
name: "TestStyle",
fontname: "Arial",
fontsize: "20",
..Style::default()
};
let ass_string = style.to_ass_string();
assert!(ass_string.starts_with("Style: TestStyle,Arial,20,"));Sourcepub fn to_ass_string_with_format(&self, format: &[&str]) -> String
pub fn to_ass_string_with_format(&self, format: &[&str]) -> String
Convert style to ASS string with specific format
Generates an ASS style line according to the provided format specification. This allows handling both V4+ and V4++ formats, as well as custom formats.
§Arguments
format- Field names in order (e.g., [“Name”, “Fontname”, “Fontsize”, …])
§Examples
let style = Style {
name: "Simple",
fontname: "Arial",
fontsize: "16",
..Style::default()
};
let format = vec!["Name", "Fontname", "Fontsize"];
assert_eq!(
style.to_ass_string_with_format(&format),
"Style: Simple,Arial,16"
);Sourcepub fn validate_spans(&self, source_range: &Range<usize>) -> bool
pub fn validate_spans(&self, source_range: &Range<usize>) -> bool
Validate all spans in this Style reference valid source
Debug helper to ensure zero-copy invariants are maintained. Validates that all string references point to memory within the specified source range.
Only available in debug builds to avoid performance overhead.
Trait Implementations§
impl<'a> Eq for Style<'a>
Source§impl<'a> Serialize for Style<'a>
impl<'a> Serialize for Style<'a>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl<'a> StructuralPartialEq for Style<'a>
Auto Trait Implementations§
impl<'a> Freeze for Style<'a>
impl<'a> RefUnwindSafe for Style<'a>
impl<'a> Send for Style<'a>
impl<'a> Sync for Style<'a>
impl<'a> Unpin for Style<'a>
impl<'a> UnsafeUnpin for Style<'a>
impl<'a> UnwindSafe for Style<'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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().