pub struct App {Show 17 fields
pub mode: Mode,
pub list_source: ListSource,
pub query: String,
pub results: Vec<Video>,
pub history: History,
pub selected: usize,
pub queue: Vec<Video>,
pub playlist_pos: Option<i64>,
pub now_playing: Option<Video>,
pub position: Option<f64>,
pub duration_secs: Option<f64>,
pub paused: bool,
pub video_enabled: bool,
pub status: String,
pub should_quit: bool,
pub mpv: Mpv,
pub search_rx: UnboundedReceiver<Video>,
/* private fields */
}Expand description
All state needed to drive the TUI: what’s on screen, what’s playing,
and the handle to the single long-lived mpv process.
Fields§
§mode: ModeWhether the search box or the list is currently focused.
list_source: ListSourceWhich list (App::results or App::history) is being shown.
query: StringCurrent contents of the search box.
results: Vec<Video>Results of the most recent search, filled in incrementally as
yt-dlp streams them back.
history: HistoryPersisted history of played/queued videos, loaded on startup and saved back to disk after every selection.
selected: usizeIndex of the highlighted item in the currently active list.
queue: Vec<Video>Videos sent to mpv so far, in the order mpv’s own playlist should have them (mirrors mpv’s internal playlist).
playlist_pos: Option<i64>mpv’s current playlist-pos, polled every tick; None before the
first successful poll.
now_playing: Option<Video>The video mpv is currently on, if any.
position: Option<f64>Current playback position in seconds, polled from mpv every tick.
duration_secs: Option<f64>Duration of the current track in seconds, polled from mpv every tick.
paused: boolWhether mpv is currently paused.
video_enabled: boolWhether the video track is currently enabled (vs. audio-only).
status: StringFree-form message shown in the status bar.
should_quit: boolSet to true to make the main loop exit on the next iteration.
mpv: MpvThe single, long-lived mpv instance this app controls.
search_rx: UnboundedReceiver<Video>Receiving end of the channel yt-dlp search results stream over;
drained into App::results by App::drain_search_results.
Implementations§
Source§impl App
impl App
Sourcepub async fn new() -> Result<Self>
pub async fn new() -> Result<Self>
Loads the saved history and spawns the single mpv instance used
for the lifetime of the app. Fails only if mpv itself can’t start
(see crate::mpv::Mpv::spawn).
Sourcepub fn drain_search_results(&mut self)
pub fn drain_search_results(&mut self)
Drains the search channel; called on every turn of the main loop.
Sourcepub fn start_search(&mut self)
pub fn start_search(&mut self)
Kicks off a new search for App::query in the background,
clearing any previous results and switching to
ListSource::Search. Does nothing if the query is blank.
Sourcepub fn toggle_history_view(&mut self)
pub fn toggle_history_view(&mut self)
Toggles between viewing the last search’s results and the saved history, without needing to search YouTube again.
Sourcepub fn move_selection(&mut self, delta: i32)
pub fn move_selection(&mut self, delta: i32)
Moves the selection cursor in the active list by delta,
clamped to the list’s bounds. Negative values move up.
Sourcepub async fn enqueue_selected(&mut self)
pub async fn enqueue_selected(&mut self)
Enter/‘a’: joins mpv’s queue (append-play) without interrupting whatever’s already playing; if mpv is idle, starts playing right away. This is the default behavior when selecting a video.
Sourcepub async fn replace_selected(&mut self)
pub async fn replace_selected(&mut self)
‘r’: plays now, replacing mpv’s entire playlist (clears the queue).
Sourcepub async fn clear_queue(&mut self) -> Result<()>
pub async fn clear_queue(&mut self) -> Result<()>
Clears the entire queue and stops playback.
Sourcepub async fn toggle_pause(&mut self) -> Result<()>
pub async fn toggle_pause(&mut self) -> Result<()>
Toggles play/pause on the currently loaded track.
Sourcepub async fn seek(&mut self, seconds: f64) -> Result<()>
pub async fn seek(&mut self, seconds: f64) -> Result<()>
Seeks by seconds relative to the current position (negative
seeks backward).
Sourcepub async fn next_track(&mut self) -> Result<()>
pub async fn next_track(&mut self) -> Result<()>
Skips to the next track in mpv’s playlist, if any.
Sourcepub async fn prev_track(&mut self) -> Result<()>
pub async fn prev_track(&mut self) -> Result<()>
Skips to the previous track in mpv’s playlist, if any.
Sourcepub async fn toggle_video(&mut self) -> Result<()>
pub async fn toggle_video(&mut self) -> Result<()>
Toggles video on/off at runtime (without reopening mpv or the stream) — works because the format resolved by mpv’s hook already includes the video track by default; this just enables/disables it.
Sourcepub async fn refresh_progress(&mut self)
pub async fn refresh_progress(&mut self)
Called on every tick of the main loop to keep position, duration, playlist index, and pause state synced with the real mpv (via get_property over the IPC socket).
Auto Trait Implementations§
impl !RefUnwindSafe for App
impl !UnwindSafe for App
impl Freeze for App
impl Send for App
impl Sync for App
impl Unpin for App
impl UnsafeUnpin for App
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<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 more