Skip to main content

Window

Struct Window 

Source
pub struct Window {
Show 31 fields pub state: WindowState, pub priority: u8, pub anchor_point: AnchorPoint, pub anchor_vertical: u8, pub anchor_horizontal: u8, pub relative_position: bool, pub row_count: u8, pub column_count: u8, pub row_lock: bool, pub column_lock: bool, pub window_style: u8, pub pen_style: u8, pub justify: Justify, pub print_direction: PrintDirection, pub scroll_direction: ScrollDirection, pub word_wrap: bool, pub fill_color: Color, pub fill_opacity: Opacity, pub border_color: Color, pub border_type: EdgeType, pub pen_size: PenSize, pub pen_offset: PenOffset, pub font_style: FontStyle, pub italics: bool, pub underline: bool, pub edge_type: EdgeType, pub edge_color: Color, pub fg_color: Color, pub fg_opacity: Opacity, pub bg_color: Color, pub bg_opacity: Opacity, /* private fields */
}
Available on crate feature decode only.
Expand description

A decoded CEA-708 caption window (§8.4 window model).

Holds the window attributes set by DefineWindow / SetWindowAttributes, the pen attributes set by SetPenAttributes / SetPenColor, and the painted text grid. Only created when a DefineWindow for its ID is received.

Fields§

§state: WindowState

Whether the window is currently displayed.

§priority: u8

Window priority, 0 (highest) – 7.

§anchor_point: AnchorPoint

Anchor point (which corner/edge/centre the anchor coordinates refer to).

§anchor_vertical: u8

Anchor vertical coordinate.

§anchor_horizontal: u8

Anchor horizontal coordinate.

§relative_position: bool

true if the anchor coordinates are relative (percent).

§row_count: u8

Row count (virtual rows; = rc + 1).

§column_count: u8

Column count (virtual cols; = cc + 1).

§row_lock: bool

Row lock.

§column_lock: bool

Column lock.

§window_style: u8

Window-style preset ID (0–7) requested in the last DefineWindow.

§pen_style: u8

Pen-style preset ID (0–7) requested in the last DefineWindow.

§justify: Justify

Justification.

§print_direction: PrintDirection

Print direction.

§scroll_direction: ScrollDirection

Scroll direction.

§word_wrap: bool

Word wrap.

§fill_color: Color

Window fill colour.

§fill_opacity: Opacity

Window fill opacity.

§border_color: Color

Border colour.

§border_type: EdgeType

Border type (none / raised / depressed / uniform / shadow).

§pen_size: PenSize

Pen size.

§pen_offset: PenOffset

Pen offset (subscript/normal/superscript).

§font_style: FontStyle

Font style.

§italics: bool

Pen italics.

§underline: bool

Pen underline.

§edge_type: EdgeType

Pen edge type.

§edge_color: Color

Pen edge colour (SPC parm3, §8.10.5.10) — distinct from the window’s border_color (SWA parm2, §8.10.5.8): the edge is drawn around each glyph per edge_type, the border is drawn around the whole window.

§fg_color: Color

Pen foreground colour.

§fg_opacity: Opacity

Pen foreground opacity.

§bg_color: Color

Pen background colour.

§bg_opacity: Opacity

Pen background opacity.

Implementations§

Source§

impl Window

Source

pub fn text(&self) -> String

The window’s visible text, non-empty rows joined with \n, per-row trailing spaces removed. Blank rows (interior or trailing) are dropped entirely rather than emitted as an empty line: a run of them would otherwise produce consecutive \ns, which downstream consumers (e.g. timed-metadata’s WebVTT cue writer) read as a cue-block terminator.

Examples found in repository?
examples/decode_cea708.rs (line 41)
7fn main() {
8    let mut dec = Cea708Decoder::new();
9
10    // Build a Caption Channel Packet carrying one Service Block for service 1
11    // that: DefineWindow DF0 (visible, 2 rows × 16 cols), writes "HI THERE".
12    let block: &[u8] = &[
13        0x98, // DefineWindow DF0
14        0x20, // parm1: visible=YES, priority 0
15        0x00, // parm2: rp=0, anchor vertical 0
16        0x00, // parm3: anchor horizontal 0
17        0x01, // parm4: anchor point 0, row count = 1+1 = 2
18        0x0F, // parm5: column count = 15+1 = 16
19        0x00, // parm6: window/pen style 0 (auto)
20        b'H', b'I', b' ', b'T', b'H', b'E', b'R', b'E',
21    ];
22
23    // Service Block header: service_number = 1, block_size = block.len().
24    let mut sb: Vec<u8> = Vec::new();
25    sb.push((1 << 5) | (block.len() as u8));
26    sb.extend_from_slice(block);
27
28    // CCP header: sequence_number 0, packet_size_code covers the data.
29    let size_code = (sb.len().div_ceil(2) + 1) as u8;
30    let mut ccp: Vec<u8> = Vec::new();
31    ccp.push(size_code & 0x3F);
32    ccp.extend_from_slice(&sb);
33
34    dec.push_packet(&ccp);
35
36    println!("Service 1 text : {:?}", dec.service_text(1));
37    if let Some(w) = dec.windows(1)[0].as_ref() {
38        println!("Window 0 state : {}", w.state);
39        println!("Window 0 rows  : {}", w.row_count);
40        println!("Window 0 cols  : {}", w.column_count);
41        println!("Window 0 text  : {:?}", w.text());
42    }
43}

Trait Implementations§

Source§

impl Clone for Window

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Window

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Window

Source§

impl PartialEq for Window

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Window

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Window

Auto Trait Implementations§

§

impl Forget for Window

§

impl Freeze for Window

§

impl Move for Window

§

impl RefUnwindSafe for Window

§

impl Send for Window

§

impl Sync for Window

§

impl Unpin for Window

§

impl UnsafeUnpin for Window

§

impl UnwindSafe for Window

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.