Skip to main content

SharedPlayerState

Struct SharedPlayerState 

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

Shared player state — atomics for lock-free reads from UI thread.

The engine writes these, the UI reads them. No mutexes in the hot path.

Implementations§

Source§

impl SharedPlayerState

Source

pub fn new() -> Arc<Self> ⓘ

Source

pub fn playback_state(&self) -> PlaybackState

Source

pub fn set_playback_state(&self, state: PlaybackState)

Source

pub fn is_waiting(&self) -> bool

Whether the player is waiting for a track it was asked for to arrive. Stopped while waiting, the track opens playing; paused, it opens paused.

Source

pub fn wants_to_play(&self) -> bool

Playing, or waiting for a track that will open playing: what a play/pause toggle pauses.

Source

pub fn is_idle(&self) -> bool

Nothing loaded and nothing waited for: where adding tracks starts them.

Source

pub fn set_transport(&self, state: PlaybackState, waiting: bool)

Publish the playback state and the wait together.

Source

pub fn position_ms(&self) -> u64

Where the playhead is, read off the samples the output has played, so it is right whenever it is asked and nothing has to keep it up to date.

Source

pub fn set_position_ms(&self, pos: u64)

Source

pub fn playhead_moving(&self) -> bool

Set by the player while a renderer is the output. A change to it is a change clients are told about: the clock only moves when the renderer is heard from, or when a command moved it. Whether the playhead is advancing on its own. Playing, but held, while a renderer has been told to play and has not yet started: a client counting on from the command would run ahead of the sound.

A renderer playing a file keeps its clock here; one playing a stream processed here keeps it on the timeline, in time into the stream.

Source

pub fn renderer(&self) -> Option<Output>

The renderer this koan is playing to, when it is not its own output.

Source

pub fn track_info(&self) -> Option<TrackInfo>

Source

pub fn set_track_info(&self, info: Option<TrackInfo>)

Source

pub fn seekable_ms(&self) -> u64

How far into the currently playing track a seek can land.

A track on disk is seekable end to end. One still downloading is seekable only as far as its bytes reach: bytes map to time by the average bitrate, exact for lossless and CBR and drifting on VBR, which is what SEEK_SAFETY_MS covers. Zero when nothing is playing.

The one value both the clamp in Player::seek and the extent front ends draw on the seek bar come from — a bar that shows a reachable position the player then refuses is worse than no bar.

Source

pub fn duration_ms(&self) -> u64

The duration to show for what is playing.

The container’s own answer wherever it gave one. A partial file that could not be read far enough to state a duration has none, and the library’s figure stands in — it came from the server, it is right, and a transport that reads 0:00 for nine hours of music is worse than one reading a figure the container has not caught up with yet.

Source

pub fn seek_ceiling_ms(&self) -> Option<u64>

seekable_ms, but None when the whole track is reachable — which is every track that is not mid-download. What a front end draws a boundary from: no boundary is the normal case and should cost no mark.

Source

pub fn current_download_fraction(&self) -> Option<f64>

Download fraction (0.0..1.0) for the currently playing track, if streaming. Returns None for fully-downloaded or non-playing tracks.

Source

pub fn request_quit(&self)

Source

pub fn quit_requested(&self) -> bool

Source

pub fn signal_metadata_refresh(&self)

Signal that metadata has been refreshed mid-stream (e.g. download completed). The UI loop calls take_metadata_refresh() to consume this flag and force a souvlaki/cover-art update without waiting for a track change.

Source

pub fn take_metadata_refresh(&self) -> bool

Returns true and clears the flag if a metadata refresh is pending.

Source

pub fn output_sample_rate(&self) -> Option<u32>

None until a track has started and the device rate is known.

Source

pub fn set_output_sample_rate(&self, rate: u32)

Source

pub fn clear_output_sample_rate(&self)

Back to “not known yet”, for the window where the device is between rates. A switch takes as long as the hardware needs to reclock — the better part of a second on USB — and the previous track’s rate is not an answer for this one.

Source

pub fn dsp(&self) -> Option<DspStatus>

Source

pub fn set_dsp(&self, status: Option<DspStatus>)

Source

pub fn play_mode(&self) -> PlayMode

Source

pub fn set_play_mode(&self, mode: PlayMode)

The player’s publish, and nothing else — but for a front end that mirrors another process’s player into a state of its own, as it mirrors the playback state. The mode is saved with the queue, so a change moves the content version.

Source

pub fn playlist_version(&self) -> u64

Source

pub fn content_version(&self) -> u64

Source

pub fn pending_version(&self) -> u64

See the field. Moves with every content change, and when an item goes back to Pending.

Source

pub fn downloads(&self) -> &Arc<DownloadStore> ⓘ

The transfers this player’s items are fetched by.

Source

pub fn changed(&self)

Say that something here moved, without saying what.

Every version and atomic in this struct stays exactly as it was — they are what a watcher consults to find out what changed. This is what spares it looking when nothing did. See crate::signal.

Source

pub fn add_items(&self, items: Vec<PlaylistItem>)

Append items to the playlist.

Source

pub fn insert_items_after(&self, items: Vec<PlaylistItem>, after: QueueItemId)

Insert items after a specific queue item.

Source

pub fn update_paths(&self, updates: &[(QueueItemId, PathBuf)])

Update file paths for playlist items (after organize moves files).

Source

pub fn remove_item(&self, id: QueueItemId)

Remove an item by ID.

Source

pub fn move_item(&self, id: QueueItemId, target: QueueItemId, after: bool)

Move an item relative to another entry.

Source

pub fn move_items(&self, ids: &[QueueItemId], target: QueueItemId, after: bool)

Batch move: extract items by ID, reinsert them at target position. Preserves the relative order of the moved items.

Source

pub fn set_cursor(&self, id: Option<QueueItemId>)

Set the cursor (what’s playing / should play).

Source

pub fn is_empty(&self) -> bool

Source

pub fn cursor(&self) -> Option<QueueItemId>

Source

pub fn cursor_path(&self) -> Option<PathBuf>

The path of the item under the cursor, without copying the playlist.

Source

pub fn replace_playlist( &self, items: Vec<PlaylistItem>, ) -> (Vec<PlaylistItem>, Option<QueueItemId>)

Clear the entire playlist + cursor. Swap the whole playlist for items, with no cursor, as one change. Returns what it held, for undo.

One write and one version bump, not a clear and an add. The download queue reads the playlist on its own thread whenever it changes, and an empty playlist between the two would read as nothing wanted: every transfer for a track in both the old queue and the new one let go, cancelled, and started again.

Source

pub fn clear_playlist(&self)

Source

pub fn advance_cursor_loadable(&self) -> Option<QueueItemId>

Move the cursor to the next item that can still play — the first item after the cursor that is not Failed, from the top again when the queue repeats — and return its ID. An advance is a move on, so repeating one item wraps the queue here as repeating the queue does; playing the item again at its end is the player’s call.

An item that is still downloading parks the cursor rather than being skipped, so playback resumes from it when its data lands. Skipping it would drop it from the queue for good.

With no cursor set, starts from the top. A cursor pointing at an item that is no longer in the playlist yields None — restarting from the top would silently replay the queue.

Source

pub fn lookahead_after(&self, after_id: QueueItemId) -> Option<Lookahead>

One step of the decoder’s gapless lookahead from after_id. Does not move the cursor; update_playback_state does that when the playhead gets there.

Failed items are passed over, as advance_cursor_loadable passes over them. A track still arriving is not: the decoder stops at it, the session drains, and the advance that follows waits for it. Passing over it would play the track after it and move the cursor beyond it, so it would never be heard.

The play mode decides what follows: the queue’s next item, the first again at its end when the queue repeats, or the same item when one repeats — gapless all three.

None when after_id has been removed: the lookahead then has nothing to follow, and starting from the top would gaplessly replay the queue.

Source

pub fn still_follows(&self, step: &Lookahead) -> bool

Whether the decoder would still take step: under the play mode now, next still follows after. A track it stopped at landing since is not a change, since the advance at the end of the session plays it in order; an edit that puts another track first is, and so is a change of mode that sends the queue elsewhere — a wrap once repeat is off, or a track appended after the one a wrap left from.

Source

pub fn retreat_cursor(&self) -> Option<(QueueItemId, PathBuf)>

Retreat cursor to the previous item. Returns (id, path) if found. For prev_track — goes to the item before cursor regardless of load state, and from the first to the last while repeat is on.

Source

pub fn update_item_state(&self, id: QueueItemId, new_state: ItemState)

Update the load state of a playlist item.

Source

pub fn item_state(&self, id: QueueItemId) -> Option<ItemState>

An item’s own state, without the rest of it.

Source

pub fn update_item_metadata( &self, id: QueueItemId, title: String, artist: String, album_artist: String, album: String, duration_ms: Option<u64>, )

Take what a finished download’s own tags can add.

Streaming starts on partial Symphonia tags, so an item with nothing behind it takes the lot once the whole file is there. An item that came out of the library does not: the record is what the queue was built from and what every other track on it carries, and a file whose tags disagree — a server album titled one way, the file inside titled another — would split its album in two the moment it finished downloading. The duration is the file’s to know either way.

Source

pub fn item_playback_source(&self, id: QueueItemId) -> Option<PlaybackSource>

Get the playback source for an item if it’s ready to play. Returns None if not enough data is available yet.

Source

pub fn reset_items_with_missing_files(&self) -> Vec<(i64, QueueItemId)>

Put back to Pending every queue item whose file has gone, and say which they were so they can be fetched again.

The queue holds paths, and clearing downloads deletes the files under them. An item left claiming Ready opens nothing when it is played — it is not broken, it is a remote track that has to be fetched a second time. Only items with a database row behind them: one without has nowhere to be fetched from, and parking the cursor on it would be worse than letting it fail honestly.

Source

pub fn item_path_if_ready(&self, id: QueueItemId) -> Option<PathBuf>

The item’s path if it is Ready. A caller that can stream wants item_playback_source.

Source

pub fn is_cursor(&self, id: QueueItemId) -> bool

Source

pub fn same_album_item_ids(&self, id: QueueItemId) -> Vec<QueueItemId>

Get QueueItemIds of all playlist items sharing the same album as the given item. Matches on both album name and album artist to avoid false positives (e.g. two different “Greatest Hits” by different artists).

Source

pub fn pending_downloads(&self) -> Vec<(i64, QueueItemId)>

Every playlist item still waiting for its file that has a track to fetch, as (db_id, QueueItemId), in the order the player will reach it: from the cursor to the end, then from the top. What the download queue fetches, and in that order — the tracks before the cursor are the ones least likely to be played next.

Source

pub fn playback_order(&self) -> Vec<(i64, QueueItemId)>

Every entry with a library track, in the order pending_downloads gives, whatever its state: what the cache has to hold, downloaded or not, for the player to reach it.

Source

pub fn item_db_id(&self, id: QueueItemId) -> Option<i64>

Get the db_id for a specific playlist item.

Source

pub fn item_load_state(&self, id: QueueItemId) -> Option<LoadState>

Get the load state of a specific playlist item.

Source

pub fn snapshot_playlist(&self) -> (Vec<PlaylistItem>, Option<QueueItemId>)

Get the full playlist snapshot (items + cursor) for undo of ClearPlaylist.

Source

pub fn get_item(&self, id: QueueItemId) -> Option<PlaylistItem>

Get an item by ID (for undo of RemoveFromPlaylist).

Source

pub fn item_before(&self, id: QueueItemId) -> Option<QueueItemId>

Get the ID of the item immediately before the given ID (None if first).

Source

pub fn reorder_to(&self, order: &[QueueItemId])

Put the items in exactly this order.

Items not named keep their relative order and follow at the end, so a stale order cannot lose anything. The items themselves are moved, not rebuilt: their ids, load states and download progress are what the rest of the player is holding on to.

Source

pub fn shuffle_order(&self) -> Vec<(QueueItemId, Option<u32>)>

Every item’s id and where it stood before shuffling, in queue order: what undoing a shuffle puts back.

Source

pub fn restore_shuffle_order(&self, order: &[(QueueItemId, Option<u32>)])

Put back an order shuffle_order read, positions before shuffling included. Items not named keep theirs and follow, as in reorder_to.

Source

pub fn shuffle_after_cursor(&self)

Note where every item stands, then put the items after the cursor in a random order — all of them with no cursor. The playing item stays where it is, so nothing that is heard changes.

Source

pub fn shuffle_from(&self, start: QueueItemId)

A queue arriving whole while shuffle is on — replaced, or added to an empty one — plays shuffled: start first, the rest in a random order after it, each item noting where it was given so turning shuffle off puts the queue back as it came. A queue that already carries those notes, a shuffled session restored, is left as it was saved.

Source

pub fn unshuffle(&self)

Put the items shuffle moved back in the order they had before it, in the places such items occupy now. An item added since keeps its place.

Source

pub fn items_before( &self, ids: &[QueueItemId], ) -> Vec<(QueueItemId, Option<QueueItemId>)>

For each ID, the ID of the item before it (or None if first), returned in playlist order regardless of the order ids arrives in.

Undo replays these left to right, so an item whose recorded predecessor is also in ids must come after it — otherwise the predecessor is missing at replay time and the item lands at the end of the playlist instead.

Source

pub fn surviving_item_before( &self, id: QueueItemId, removed: &[QueueItemId], ) -> Option<QueueItemId>

The nearest item before id that is not itself being removed — where playback resumes from after a batch delete that takes out the cursor. None means resume from the top of what survives.

Source

pub fn restore_playlist( &self, items: Vec<PlaylistItem>, cursor: Option<QueueItemId>, )

Restore a full playlist from snapshot (for redo of ClearPlaylist undo).

Source

pub fn remove_items(&self, ids: &[QueueItemId])

Remove multiple items by IDs.

Source

pub fn insert_item_at(&self, item: PlaylistItem, after: Option<QueueItemId>)

Insert a single item after a given ID (or at front if None).

Source

pub fn move_item_to(&self, id: QueueItemId, after: Option<QueueItemId>)

Move a single item to after after (or to front if None).

Source

pub fn move_items_to(&self, entries: &[(QueueItemId, Option<QueueItemId>)])

Batch move: reposition each item to after its given predecessor. Processes in order so earlier insertions don’t corrupt later positions.

Source

pub fn derive_visible_queue(&self) -> VisibleQueueSnapshot

Derive the visible queue from the playlist + cursor. O(n). Called once per UI tick.

Trait Implementations§

Source§

impl Debug for SharedPlayerState

Source§

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

Formats the value using the given formatter. Read more

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Paint for T
where T: ?Sized,

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Primary].

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Fixed].

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to [Color :: Rgb].

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Black].

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Red].

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Green].

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Yellow].

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Blue].

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Magenta].

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: Cyan].

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: White].

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlack].

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightRed].

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightGreen].

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightYellow].

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightBlue].

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightCyan].

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to [Color :: BrightWhite].

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Primary].

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Fixed].

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to [Color :: Rgb].

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Black].

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Red].

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Green].

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Yellow].

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Blue].

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Magenta].

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: Cyan].

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: White].

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlack].

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightRed].

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightGreen].

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightYellow].

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightBlue].

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightMagenta].

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightCyan].

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to [Color :: BrightWhite].

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Bold].

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Dim].

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Italic].

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Underline].

§Example
println!("{}", value.underline());

Returns self with the attr() set to [Attribute :: Blink].

§Example
println!("{}", value.blink());

Returns self with the attr() set to [Attribute :: RapidBlink].

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Invert].

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Conceal].

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to [Attribute :: Strike].

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Mask].

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Wrap].

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Linger].

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1:

renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to [Quirk :: Clear].

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Resetting].

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: Bright].

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to [Quirk :: OnBright].

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more