Skip to main content

MediaSyntax

Struct MediaSyntax 

Source
pub struct MediaSyntax;
Expand description

Reifies every media sort as inspectable Rust syntax.

One interpreter ties the whole knot: the sorts are shared, so the classes are only meaningful together and a single reification serves all of them.

Trait Implementations§

Source§

impl ArtifactAlg for MediaSyntax

Source§

fn artifact( &self, id: impl Into<String>, kind: ArtifactKind, metadata: Self::Metadata, ) -> Self::Artifact

Defines one artifact independently of collection storage.
Source§

impl Clone for MediaSyntax

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 Copy for MediaSyntax

Source§

impl Debug for MediaSyntax

Source§

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

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

impl Default for MediaSyntax

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl ExtractionAlg for MediaSyntax

Source§

fn media( &self, id: impl Into<String>, metadata: Self::Metadata, formats: impl IntoIterator<Item = Self::Format>, ) -> Self::Extraction

Defines a fully described media extraction.
Source§

fn url_reference( &self, url: impl Into<String>, extractor: Option<Self::Extractor>, transparent: bool, ) -> Self::Extraction

Defines a URL requiring another extraction step.
Source§

fn extraction_collection( &self, id: Option<String>, kind: CollectionKind, metadata: Self::Metadata, entries: impl IntoIterator<Item = Self::Extraction>, ) -> Self::Extraction

Defines an ordered extraction collection.
Source§

impl ExtractionViewAlg for MediaSyntax

Source§

fn as_media(&self, extraction: Extraction) -> Option<Media>

Observes the single media item an extraction denotes, exactly when it denotes one.
Source§

impl FormatAlg for MediaSyntax

Source§

fn format( &self, id: impl Into<String>, metadata: Self::Metadata, ) -> Self::Format

Defines one representation from its identity and everything observed about it.
Source§

impl FormatPredicateAlg for MediaSyntax

Source§

fn any_format(&self) -> Self::Predicate

Defines the predicate accepting every format.
Source§

fn format_id(&self, id: impl Into<String>) -> Self::Predicate

Defines the predicate accepting one format identity.
Source§

fn observed_format(&self, key: impl Into<String>) -> Self::Predicate

Defines the predicate accepting formats stating the named observation.
Source§

fn text_format( &self, key: impl Into<String>, value: impl Into<String>, ) -> Self::Predicate

Defines the predicate accepting one textual observation.
Source§

fn flag_format(&self, key: impl Into<String>, value: bool) -> Self::Predicate

Defines the predicate accepting one stated truth.
Source§

fn number_format( &self, key: impl Into<String>, comparison: FormatComparison, value: f64, ) -> Self::Predicate

Defines the predicate comparing one numeric observation.
Source§

fn all_formats( &self, left: Self::Predicate, right: Self::Predicate, ) -> Self::Predicate

Defines conjunction.
Source§

fn not_format(&self, predicate: Self::Predicate) -> Self::Predicate

Defines negation.
Source§

impl FormatPredicateMatchAlg for MediaSyntax

Source§

fn format_matches(&self, predicate: &FormatPredicate, format: &Format) -> bool

Observes whether a format satisfies a predicate.
Source§

impl FormatSelectionAlg for MediaSyntax

Source§

fn best_format(&self, predicate: Self::Predicate) -> Self::Selection

Defines selection of the most preferred matching format.
Source§

fn worst_format(&self, predicate: Self::Predicate) -> Self::Selection

Defines selection of the least preferred matching format.
Source§

fn merge_formats( &self, selections: impl IntoIterator<Item = Self::Selection>, ) -> Self::Selection

Defines ordered combination requiring every child selection.
Source§

fn fallback_formats( &self, selections: impl IntoIterator<Item = Self::Selection>, ) -> Self::Selection

Defines left-biased choice of the first successful child selection.
Source§

impl FormatSelectionApplyAlg for MediaSyntax

Source§

fn select_formats<'a>( &self, formats: &'a [Format], selection: &FormatSelection, ) -> Option<Vec<&'a Format>>

Chooses the formats one program denotes, in program order.
Source§

impl FormatViewAlg for MediaSyntax

Source§

fn format_text<'a>(&self, format: &'a Format, key: &str) -> Option<&'a str>

Observes one named value of a format as text.
Source§

impl MediaSorts for MediaSyntax

Source§

type Value = InfoValue

Represents one metadata value.
Source§

type Metadata = InfoRecord

Represents one metadata record.
Source§

type Format = Format

Represents one alternative representation of a media item.
Source§

type Artifact = Artifact

Represents one produced artifact.
Source§

type Media = Media

Represents one fully described media item.
Source§

type Extraction = Extraction

Represents one extraction result.
Source§

type Extractor = ExtractorKey

Represents one extractor identity.
Source§

type Predicate = FormatPredicate

Represents one predicate over a format.
Source§

type Selection = FormatSelection

Represents one format-selection program.
Source§

type Output = PathBuf

Represents one portable output name.
Source§

impl MediaViewAlg for MediaSyntax

Source§

fn media_id<'a>(&self, media: &'a Media) -> &'a str

Observes the media identity.
Source§

fn media_title<'a>(&self, media: &'a Media) -> Option<&'a str>

Observes the media title exactly when one was extracted.
Source§

fn media_formats<'a>(&self, media: &'a Media) -> &'a [Format]

Observes the formats in extractor order.
Source§

impl MetadataAlg for MediaSyntax

Source§

fn empty_metadata(&self) -> Self::Metadata

Defines the neutral metadata record.
Source§

fn null_metadata(&self) -> Self::Value

Defines unavailable metadata.
Source§

fn boolean_metadata(&self, value: bool) -> Self::Value

Defines a boolean observation.
Source§

fn integer_metadata(&self, value: i64) -> Self::Value

Defines an integral observation.
Source§

fn float_metadata(&self, value: f64) -> Self::Value

Defines a non-integral observation.
Source§

fn string_metadata(&self, value: impl Into<String>) -> Self::Value

Defines textual metadata.
Source§

fn list_metadata( &self, values: impl IntoIterator<Item = Self::Value>, ) -> Self::Value

Defines an ordered metadata sequence.
Source§

fn record_metadata(&self, record: Self::Metadata) -> Self::Value

Defines a nested metadata record.
Source§

fn metadata( &self, fields: impl IntoIterator<Item = (String, Self::Value)>, ) -> Self::Metadata

Defines a record from fields, with later equal keys replacing earlier fields.
Source§

impl MetadataViewAlg for MediaSyntax

Source§

fn metadata_text<'a>( &self, metadata: &'a InfoRecord, key: &str, ) -> Option<&'a str>

Observes the text one field states, when it states text.
Source§

fn metadata_number(&self, metadata: &InfoRecord, key: &str) -> Option<i64>

Observes the whole number one field states, when it states one.
Source§

impl OutputNameAlg for MediaSyntax

Source§

fn output_name(&self, component: String) -> Self::Output

Defines an output from one already normalized file component.

Auto Trait Implementations§

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<This> ArtifactLaws<This> for This
where This: MetadataAlg + ArtifactAlg,

Source§

fn artifact_laws(&self) -> Result<(), Error>
where <This as MediaSorts>::Artifact: PartialEq + Debug, <This as MediaSorts>::Metadata: Clone,

Checks that an artifact is exactly its identity, its role, and its observations.

The laws checked are:

  1. definition is a function of identity, role, and observations;
  2. each of the three is significant, so changing one changes the artifact.
§Errors

Returns the first violated law.

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<This> FormatLaws<This> for This

Source§

fn format_laws(&self) -> Result<(), Error>

Checks that a format states back exactly what it was defined with.

The laws checked are:

  1. an observation a format states is the one it is observed under;
  2. distinct observation names are independent;
  3. an unstated observation is absent rather than defaulted.
§Errors

Returns the first violated law.

Source§

impl<This> FormatPredicateExt<This> for This
where This: FormatPredicateAlg,

Source§

fn has_audio(&self) -> <This as MediaSorts>::Predicate

Defines formats containing audio.

Source§

fn has_video(&self) -> <This as MediaSorts>::Predicate

Defines formats containing video.

Source§

fn format_extension( &self, extension: impl Into<String>, ) -> <This as MediaSorts>::Predicate

Defines formats stating one container or filename extension.

Source§

fn at_most( &self, key: impl Into<String>, value: f64, ) -> <This as MediaSorts>::Predicate

Defines formats whose observation is no greater than the stated number.

Source§

fn at_least( &self, key: impl Into<String>, value: f64, ) -> <This as MediaSorts>::Predicate

Defines formats whose observation is no smaller than the stated number.

Source§

fn exactly( &self, key: impl Into<String>, value: f64, ) -> <This as MediaSorts>::Predicate

Defines formats whose observation equals the stated number.

Source§

fn less_than( &self, key: impl Into<String>, value: f64, ) -> <This as MediaSorts>::Predicate

Defines formats whose observation is smaller than the stated number.

Source§

fn greater_than( &self, key: impl Into<String>, value: f64, ) -> <This as MediaSorts>::Predicate

Defines formats whose observation is greater than the stated number.

Source§

fn progressive_format(&self) -> <This as MediaSorts>::Predicate

Defines formats containing both audio and video.

Source§

fn audio_only_format(&self) -> <This as MediaSorts>::Predicate

Defines formats containing audio and no video.

Source§

fn video_only_format(&self) -> <This as MediaSorts>::Predicate

Defines formats containing video and no audio.

Source§

impl<This, Predicate> FormatSelectionProgramExt<This, Predicate> for This
where This: FormatPredicateAlg<Predicate = Predicate, Predicate = Predicate> + FormatSelectionAlg,

Source§

fn best_progressive_format(&self) -> <This as MediaSorts>::Selection

Defines the most preferred progressive format.

Source§

fn preferred_progressive_format( &self, id: impl Into<String>, ) -> <This as MediaSorts>::Selection

Defines an exact format with a progressive fallback.

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<This> GaugeLaws<This> for This

Source§

fn gauge_laws(&self) -> Result<(), Error>

Checks that a gauge states a share without claiming more resolution than it has.

The laws checked are:

  1. a gauge occupies its stated width whatever share it states;
  2. no share is stated as filled before it is reached, and none is stated twice;
  3. nothing stated is nothing filled, and everything stated fills the whole track;
  4. the stated text occupies exactly one cell per counted cell.
§Errors

Returns the first violated law.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<This> IntoExt<This> for This

Source§

fn to<R>(self) -> R
where This: Into<R>,

A version of Into::into function that can be used to explicitly specify the target conversion type.

use alux_sdk::*;
// `Into` requires context to infer the type,
let _: i64 = Into::into(42_i8);
// The opposite `From` requires context to infer the type,
let _: i64 = From::from(42_i8);
// `.to()` can be used in the same way as a postfix function (the same as `.into()`),
let _: i64 = 42_i8.to();
// but also with the type specified explicitly.
let _ = 42_i8.to::<i64>();
// Especially useful to chain multiple conversions inline.
let _: i64 = 42_i8.to::<i16>().to::<i32>().into();
Source§

impl<This> IntoIteratorExt<This> for This

Source§

fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
where This: Iterator<Item = Result<T, E>>,

A variant of the try_collect and collect_vec combined function from the Itertools library. The materialized value is a Vec inside a Result object.

Returns the first error without collecting later values.

use alux_sdk::*;

let values = [Ok::<_, &str>(1), Ok(2), Ok(3)]
    .into_iter()
    .try_collect_vec();

assert_eq!(values, Ok(vec![1, 2, 3]));
Source§

fn collect_exact<T>(self, n: usize) -> Option<Vec<T>>
where This: Iterator<Item = T>,

Takes exactly n elements from the iterator.

Returns Some(Vec<T>) if the iterator yields exactly n elements, otherwise returns None.

use alux_sdk::*;

let v = [1, 2, 3];

assert_eq!(v.iter().copied().collect_exact(3), Some(vec![1, 2, 3]));
assert_eq!(v.iter().copied().collect_exact(4), None);
assert_eq!(v.iter().copied().collect_exact(2), None);
Source§

fn try_unzip<A, B, E>(self) -> Result<(Vec<A>, Vec<B>), E>
where This: IntoIterator<Item = Result<(A, B), E>>,

Efficiently splits an iterator of Result<(A, B), E> into two Vecs, short-circuiting on error.

Consumes the iterator, collecting all A elements into one vector and all B elements into another, without first allocating an intermediate vector of tuples. Returns the tuple (Vec<A>, Vec<B>) on success, or the first error encountered.

use alux_sdk::*;

let input = vec![Ok((1, "x")), Ok((2, "y"))];
let (xs, ys) = input.try_unzip::<_, _, ()>().unwrap();

assert_eq!(xs, vec![1, 2]);
assert_eq!(ys, vec!["x", "y"]);
Source§

impl<This> MediaOutputExt<This> for This

Source§

fn media_output_path( &self, media: &<This as MediaSorts>::Media, format: &<This as MediaSorts>::Format, target: &OutputTarget, ) -> PathBuf

Defines the final path one media item publishes its selected format at.

Source§

impl<This> MediaStreamsExt<This> for This
where This: FormatPredicateAlg,

Source§

fn stream_role_format( &self, streams: MediaStreams, ) -> <This as MediaSorts>::Predicate

Defines the predicate accepting exactly the formats those roles require.

Source§

impl<This> MetadataExt<This> for This
where This: MetadataAlg,

Source§

fn text_metadata( &self, key: impl Into<String>, value: impl Into<String>, ) -> <This as MediaSorts>::Metadata

Defines a record containing one textual field.

Source§

impl<This> ObservationLaws<This> for This
where This: MetadataAlg,

Source§

fn observation_laws(&self) -> Result<(), Error>
where <This as MediaSorts>::Metadata: PartialEq + Debug, <This as MediaSorts>::Value: Clone,

Checks that the empty record is neutral and later equal keys replace earlier ones.

§Errors

Returns the first violated law.

Source§

impl<This> OutputNameExt<This> for This
where This: OutputNameAlg,

Source§

fn portable_output_name( &self, title: Option<&str>, fallback: &str, extension: Option<&str>, ) -> <This as MediaSorts>::Output

Defines a portable file name from title, identity, and extension.

Source§

fn portable_user_output_name( &self, input: &str, fallback_extension: Option<&str>, ) -> <This as MediaSorts>::Output

Defines a portable edited file name.

Source§

impl<This> OutputNameLaws<This> for This
where This: OutputNameAlg,

Source§

fn output_naming_laws(&self) -> Result<(), Error>

Checks that naming is a function of its inputs and yields one safe file component.

§Errors

Returns the first violated law.

Source§

impl<This> RequestSelectionExt<This> for This

Source§

fn request_selection( &self, options: &impl RequestOptionsAlg, ) -> <This as MediaSorts>::Selection

Defines the selection one request’s own choices state.

Source§

impl<This> SelectionLaws<This> for This

Source§

fn selection_laws(&self) -> Result<(), Error>
where <This as MediaSorts>::Predicate: Clone,

Checks best, worst, merge, and fallback against a catalog the scenario authors.

§Errors

Returns the first violated law.

Source§

fn check_selection_against( &self, catalog: &[<This as MediaSorts>::Format], predicate: &<This as MediaSorts>::Predicate, ) -> Result<(), Error>
where <This as MediaSorts>::Predicate: Clone,

Checks the selection laws for one catalog and predicate.

§Errors

Returns the first violated law.

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.
Source§

impl<This> YoutubeNotesExt<This> for This
where This: MetadataViewAlg,

Source§

fn granting_notes( &self, metadata: &<This as MediaSorts>::Metadata, ) -> Vec<String>

States what extraction observed about granting, in the words a reader reads.

A player response describes formats this interpreter may or may not be able to read: some state no location, some are held behind an unanswered signature, and some are served slowly on purpose. What is said here is what was counted, and nothing is said about a count the extractor did not state.