Skip to main content

ReferenceYoutubeEnv

Struct ReferenceYoutubeEnv 

Source
pub struct ReferenceYoutubeEnv { /* private fields */ }
Expand description

Interprets the Youtube query surface and resolves only the challenges it was seeded with.

Transport is a line-oriented encoding rather than HTML and JSON: decoding still reads the bytes it is handed, which is all the response laws constrain.

Implementations§

Source§

impl ReferenceYoutubeEnv

Source

pub fn solve( &mut self, challenge: YoutubeChallenge, solution: impl Into<String>, )

Seeds one challenge with the value the player program would resolve it to.

Source

pub fn executed(&self) -> Vec<YoutubeRequest>

Observes the requests executed so far, in execution order.

Source

pub fn applications(&self) -> Vec<Vec<YoutubeChallenge>>

Observes the bulk challenge applications received, in application order.

Source

pub fn watch_bytes() -> Vec<u8> ⓘ

States the watch-page bytes the reference watch URL answers with.

Source

pub fn player_bytes() -> Vec<u8> ⓘ

States the player bytes the reference player request answers with.

Trait Implementations§

Source§

impl Debug for ReferenceYoutubeEnv

Source§

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

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

impl Default for ReferenceYoutubeEnv

Source§

fn default() -> Self

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

impl YoutubeChallengeAlg for ReferenceYoutubeEnv

Source§

type Error = !

Denotes resolution failure.
Source§

fn solve_challenges( &self, program: &str, challenges: impl IntoIterator<Item = YoutubeChallenge>, ) -> Result<Self::Solutions, Self::Error>

Resolves the given challenges together under the program that poses them. Read more
Source§

impl YoutubeClientAlg for ReferenceYoutubeEnv

Source§

fn player_clients(&self) -> impl Iterator<Item = &str>

Names the clients this interpreter can claim to be, in preference order.
Source§

impl YoutubeProgramAlg for ReferenceYoutubeEnv

Source§

fn program_timestamp(&self, program: &str) -> Option<i64>

Observes the signature timestamp the program states, when it states one.
Source§

impl YoutubeRequestAlg for ReferenceYoutubeEnv

Source§

fn watch_request(&self, url: impl Into<String>) -> Self::Request

Defines watch-page retrieval.
Source§

fn player_request( &self, id: impl Into<String>, api_key: impl Into<String>, claim: &PlayerClaim, ) -> Self::Request

Defines player-catalog retrieval under what the client claims about itself. Read more
Source§

fn player_program_request(&self, url: impl Into<String>) -> Self::Request

Defines player-program retrieval.
Source§

fn media_request(&self, url: impl Into<String>) -> Self::Request

Defines direct-media retrieval.
Source§

impl YoutubeRequestBytesAlg for ReferenceYoutubeEnv

Source§

type Error = ReferenceFetchError

Denotes request execution failure.
Source§

fn youtube_request_bytes( &self, request: &Self::Request, ) -> Result<Vec<u8>, Self::Error>

Retrieves response bytes without changing request meaning. Read more
Source§

impl YoutubeResponseAlg for ReferenceYoutubeEnv

Source§

type Error = ReferenceFetchError

Denotes decoding failure.
Source§

fn decode_youtube_watch( &self, bytes: &[u8], ) -> Result<YoutubeWatchPage, Self::Error>

Decodes one watch page. Read more
Source§

fn decode_youtube_player( &self, bytes: &[u8], ) -> Result<YoutubePlayer, Self::Error>

Decodes one player response. Read more
Source§

impl YoutubeSolutionAlg for ReferenceYoutubeEnv

Source§

fn solution_of( &self, solutions: &Self::Solutions, challenge: &YoutubeChallenge, ) -> Option<String>

Observes the solution of one challenge exactly when that challenge was resolved.
Source§

impl YoutubeSorts for ReferenceYoutubeEnv

Source§

type Request = YoutubeRequest

Represents one Youtube request.
Source§

type Solutions = Vec<(YoutubeChallenge, String)>

Represents the challenges resolved by one bulk application.
Source§

impl YoutubeUrlAlg for ReferenceYoutubeEnv

Source§

fn throttle_challenge(&self, url: &str) -> Option<String>

Observes the throttling challenge a representation URL carries.
Source§

fn with_throttle(&self, url: &str, solution: &str) -> String

Replaces the throttling parameter with its solution.
Source§

fn with_signature(&self, url: &str, parameter: &str, signature: &str) -> String

Attaches a solved signature under the parameter naming it.

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<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> 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<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, ChallengeError> YoutubeChallengeExt<This, ChallengeError> for This
where This: YoutubeChallengeAlg<Error = ChallengeError> + YoutubeSolutionAlg + YoutubeUrlAlg,

Source§

fn format_challenges<'a>( &'a self, formats: impl IntoIterator<Item = &'a YoutubeFormat> + 'a, ) -> impl Iterator<Item = YoutubeChallenge> + 'a

Observes every distinct challenge the formats pose, in first-appearance order.

Source§

fn grant_format( &self, format: &YoutubeFormat, solutions: &<This as YoutubeSorts>::Solutions, ) -> YoutubeGrant

Grants one format its retrievable URL under already resolved challenges.

Source§

fn grant_formats( &self, program: &str, formats: &[YoutubeFormat], ) -> Result<Vec<YoutubeGrant>, ChallengeError>

Resolves the challenges one program poses once, and grants every format in order.

§Errors

Returns the interpreter-specific resolution failure.

Source§

impl<This, ChallengeError> YoutubeChallengeLaws<This, ChallengeError> for This
where This: YoutubeChallengeAlg<Error = ChallengeError> + YoutubeSolutionAlg + YoutubeUrlAlg,

Source§

fn youtube_granting_laws(&self) -> Result<(), Error>
where ChallengeError: Debug,

Checks that granting is total, ordered, and withholds only what stays unresolved.

The laws checked are:

  1. granting yields exactly one outcome per described format, in declaration order;
  2. a source posing no challenge is granted its stated URL unchanged;
  3. an unresolved signature withholds exactly the formats it guards, and no others;
  4. an unresolved throttling parameter governs the rate of a still retrievable URL.
§Errors

Returns the first violated law, or the interpreter’s resolution failure.

Source§

impl<This, Request> YoutubeRequestLaws<This, Request> for This
where This: YoutubeSorts<Request = Request> + YoutubeRequestAlg, Request: PartialEq + Debug,

Source§

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

Checks that each request is a function of its arguments and distinct from the others.

The laws checked are:

  1. a request is a function of the values naming it;
  2. retrieving a watch page, a player catalog, and media are three distinct requests;
  3. the player request depends on the identity, the key, and what the client claims.
§Errors

Returns the first violated law.

Source§

impl<This> YoutubeUrlLaws<This> for This
where This: YoutubeUrlAlg,

Source§

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

Checks that the two substitutions are independent and that answering is observable.

The laws checked are:

  1. a solved throttling parameter is the one the answered URL then poses;
  2. attaching a solved signature leaves the throttling challenge unchanged.
§Errors

Returns the first violated law.