ingraph 0.1.0

A declaration-driven indexing framework: records and nodes are written as Rust types, and the storage rows, the dataflow between them and the GraphQL query surface are emitted from the declaration.
Documentation
//! The SUBTITLE track's codec seat.

use mediaframe::codec::SubtitleCodec as Foreign;

/// **What a subtitle track's bytes are encoded with** — an FFmpeg subtitle codec name in the
/// lowercase canon, or the open escape for one this build's roster does not carry.
///
/// The citizen wrapping [`mediaframe::codec::SubtitleCodec`]. It is
/// [`VideoCodec`](super::VideoCodec)'s sentence over a third roster — `ass`, `subrip`,
/// `dvb_subtitle` — and the separate type is what keeps a subtitle seat from taking a value that
/// names an audio or a video codec.
///
/// Everything the video citizen documents holds here word for word — the total door, the fold at
/// construction, the canonical-slug equality, the alphabetical order over spellings, the
/// re-canonicalising conversion from the upstream value. See [`VideoCodec`](super::VideoCodec),
/// where each is argued once, and the module note for the faces and the two refusals.
#[derive(Clone, PartialEq, Eq, Hash)]
pub struct SubtitleCodec(Foreign);

impl SubtitleCodec {
  /// Read a subtitle codec name, WIDE — any case, known or not.
  ///
  /// The ONE door in, and it is total: a name the roster does not carry lands in the escape arm,
  /// ASCII-folded to the lowercase canon.
  #[inline]
  #[must_use]
  pub fn new(text: &str) -> Self {
    // `from_str` is `Infallible` upstream; the closure takes an uninhabited value, so there is no
    // panic path here. See `VideoCodec::new`, where the shape is explained.
    Self(text.parse().unwrap_or_else(|never| match never {}))
  }

  /// The wrapped upstream value, borrowed — the road to upstream's own `Unwrap`/`TryUnwrap`
  /// predicates, which this roster carries and the other two do not.
  #[inline]
  #[must_use]
  pub const fn get(&self) -> &Foreign {
    &self.0
  }

  /// The wrapped upstream value, owned. Canonical, the door having made it so.
  #[inline]
  #[must_use]
  pub fn into_inner(self) -> Foreign {
    self.0
  }

  /// The canonical slug — the text this value stores as, pages by, and crosses the wire as.
  #[inline]
  #[must_use]
  pub fn as_str(&self) -> &str {
    self.0.as_str()
  }

  /// Whether this build's roster CARRIES this codec, as against holding it in the open escape.
  ///
  /// The roster itself is
  /// [`mediaframe::codec::SubtitleCodec::ROSTER`](mediaframe::codec::SubtitleCodec#associatedconstant.ROSTER)
  /// and is not restated here.
  #[inline]
  #[must_use]
  pub fn is_registered(&self) -> bool {
    !self.0.is_other()
  }
}

super::codec_citizen!(
  SubtitleCodec,
  mediaframe::codec::SubtitleCodec,
  SubtitleCodecWire,
  "SubtitleCodecFilter"
);

#[cfg(test)]
mod tests;