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
impl ReferenceYoutubeEnv
Sourcepub fn solve(
&mut self,
challenge: YoutubeChallenge,
solution: impl Into<String>,
)
pub fn solve( &mut self, challenge: YoutubeChallenge, solution: impl Into<String>, )
Seeds one challenge with the value the player program would resolve it to.
Sourcepub fn executed(&self) -> Vec<YoutubeRequest>
pub fn executed(&self) -> Vec<YoutubeRequest>
Observes the requests executed so far, in execution order.
Sourcepub fn applications(&self) -> Vec<Vec<YoutubeChallenge>>
pub fn applications(&self) -> Vec<Vec<YoutubeChallenge>>
Observes the bulk challenge applications received, in application order.
Sourcepub fn watch_bytes() -> Vec<u8> ⓘ
pub fn watch_bytes() -> Vec<u8> ⓘ
States the watch-page bytes the reference watch URL answers with.
Sourcepub fn player_bytes() -> Vec<u8> ⓘ
pub fn player_bytes() -> Vec<u8> ⓘ
States the player bytes the reference player request answers with.
Trait Implementations§
Source§impl Debug for ReferenceYoutubeEnv
impl Debug for ReferenceYoutubeEnv
Source§impl Default for ReferenceYoutubeEnv
impl Default for ReferenceYoutubeEnv
Source§impl YoutubeChallengeAlg for ReferenceYoutubeEnv
impl YoutubeChallengeAlg for ReferenceYoutubeEnv
Source§fn solve_challenges(
&self,
program: &str,
challenges: impl IntoIterator<Item = YoutubeChallenge>,
) -> Result<Self::Solutions, Self::Error>
fn solve_challenges( &self, program: &str, challenges: impl IntoIterator<Item = YoutubeChallenge>, ) -> Result<Self::Solutions, Self::Error>
Source§impl YoutubeClientAlg for ReferenceYoutubeEnv
impl YoutubeClientAlg for ReferenceYoutubeEnv
Source§fn player_clients(&self) -> impl Iterator<Item = &str>
fn player_clients(&self) -> impl Iterator<Item = &str>
Source§impl YoutubeRequestAlg for ReferenceYoutubeEnv
impl YoutubeRequestAlg for ReferenceYoutubeEnv
Source§fn watch_request(&self, url: impl Into<String>) -> Self::Request
fn watch_request(&self, url: impl Into<String>) -> Self::Request
Source§fn player_request(
&self,
id: impl Into<String>,
api_key: impl Into<String>,
claim: &PlayerClaim,
) -> Self::Request
fn player_request( &self, id: impl Into<String>, api_key: impl Into<String>, claim: &PlayerClaim, ) -> Self::Request
Source§impl YoutubeResponseAlg for ReferenceYoutubeEnv
impl YoutubeResponseAlg for ReferenceYoutubeEnv
Source§type Error = ReferenceFetchError
type Error = ReferenceFetchError
Source§fn decode_youtube_watch(
&self,
bytes: &[u8],
) -> Result<YoutubeWatchPage, Self::Error>
fn decode_youtube_watch( &self, bytes: &[u8], ) -> Result<YoutubeWatchPage, Self::Error>
Source§fn decode_youtube_player(
&self,
bytes: &[u8],
) -> Result<YoutubePlayer, Self::Error>
fn decode_youtube_player( &self, bytes: &[u8], ) -> Result<YoutubePlayer, Self::Error>
Source§impl YoutubeSolutionAlg for ReferenceYoutubeEnv
impl YoutubeSolutionAlg for ReferenceYoutubeEnv
Source§fn solution_of(
&self,
solutions: &Self::Solutions,
challenge: &YoutubeChallenge,
) -> Option<String>
fn solution_of( &self, solutions: &Self::Solutions, challenge: &YoutubeChallenge, ) -> Option<String>
Source§impl YoutubeSorts for ReferenceYoutubeEnv
impl YoutubeSorts for ReferenceYoutubeEnv
Source§type Request = YoutubeRequest
type Request = YoutubeRequest
Source§impl YoutubeUrlAlg for ReferenceYoutubeEnv
impl YoutubeUrlAlg for ReferenceYoutubeEnv
Auto Trait Implementations§
impl !Freeze for ReferenceYoutubeEnv
impl !RefUnwindSafe for ReferenceYoutubeEnv
impl !Sync for ReferenceYoutubeEnv
impl Send for ReferenceYoutubeEnv
impl Unpin for ReferenceYoutubeEnv
impl UnsafeUnpin for ReferenceYoutubeEnv
impl UnwindSafe for ReferenceYoutubeEnv
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<This> GaugeLaws<This> for This
impl<This> GaugeLaws<This> for This
Source§fn gauge_laws(&self) -> Result<(), Error>
fn gauge_laws(&self) -> Result<(), Error>
Checks that a gauge states a share without claiming more resolution than it has.
The laws checked are:
- a gauge occupies its stated width whatever share it states;
- no share is stated as filled before it is reached, and none is stated twice;
- nothing stated is nothing filled, and everything stated fills the whole track;
- the stated text occupies exactly one cell per counted cell.
§Errors
Returns the first violated law.
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<This> IntoExt<This> for This
impl<This> IntoExt<This> for This
Source§fn to<R>(self) -> Rwhere
This: Into<R>,
fn to<R>(self) -> Rwhere
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
impl<This> IntoIteratorExt<This> for This
Source§fn try_collect_vec<T, E>(self) -> Result<Vec<T>, E>
fn try_collect_vec<T, E>(self) -> Result<Vec<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>,
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>
fn try_unzip<A, B, E>(self) -> Result<(Vec<A>, Vec<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, ChallengeError> YoutubeChallengeExt<This, ChallengeError> for This
impl<This, ChallengeError> YoutubeChallengeExt<This, ChallengeError> for This
Source§fn format_challenges<'a>(
&'a self,
formats: impl IntoIterator<Item = &'a YoutubeFormat> + 'a,
) -> impl Iterator<Item = YoutubeChallenge> + 'a
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
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>
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
impl<This, ChallengeError> YoutubeChallengeLaws<This, ChallengeError> for This
Source§fn youtube_granting_laws(&self) -> Result<(), Error>where
ChallengeError: Debug,
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:
- granting yields exactly one outcome per described format, in declaration order;
- a source posing no challenge is granted its stated URL unchanged;
- an unresolved signature withholds exactly the formats it guards, and no others;
- 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
impl<This, Request> YoutubeRequestLaws<This, Request> for This
Source§fn youtube_request_laws(&self) -> Result<(), Error>
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:
- a request is a function of the values naming it;
- retrieving a watch page, a player catalog, and media are three distinct requests;
- 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 Thiswhere
This: YoutubeUrlAlg,
impl<This> YoutubeUrlLaws<This> for Thiswhere
This: YoutubeUrlAlg,
Source§fn youtube_url_laws(&self) -> Result<(), Error>
fn youtube_url_laws(&self) -> Result<(), Error>
Checks that the two substitutions are independent and that answering is observable.
The laws checked are:
- a solved throttling parameter is the one the answered URL then poses;
- attaching a solved signature leaves the throttling challenge unchanged.
§Errors
Returns the first violated law.