pub struct Service {
pub(crate) db: Data,
services: Arc<OnceServices>,
url_preview_mutex: MutexMap<String, ()>,
federation_mutex: MutexMap<String, ()>,
mxc_state: MXCState,
video_thumbnail_slots: Semaphore,
video_thumbnail_failures: Mutex<LruCache<String, Instant>>,
}Fields§
§db: Data§services: Arc<OnceServices>§url_preview_mutex: MutexMap<String, ()>§federation_mutex: MutexMap<String, ()>§mxc_state: MXCState§video_thumbnail_slots: Semaphore§video_thumbnail_failures: Mutex<LruCache<String, Instant>>Implementations§
Source§impl Service
impl Service
pub async fn get_url_preview(&self, url: &Url) -> Result<UrlPreviewData>
Source§impl Service
impl Service
pub async fn request_url_preview(&self, url: &Url) -> Result<UrlPreviewData>
Source§impl Service
impl Service
Sourcefn preview_get(&self, url: &Url, agent: Agent) -> RequestBuilder
fn preview_get(&self, url: &Url, agent: Agent) -> RequestBuilder
Build a preview request through the preview client, carrying the headers
preview_headers applies.
Source§impl Service
impl Service
Sourcepub(super) fn preview_headers(
&self,
request: RequestBuilder,
url: &Url,
agent: Agent,
) -> RequestBuilder
pub(super) fn preview_headers( &self, request: RequestBuilder, url: &Url, agent: Agent, ) -> RequestBuilder
Apply the configured User-Agent and any origin-specific headers to a preview request.
Both are read per request rather than baked into the client, so a configuration reload takes effect without restarting the server. The configuration is bound once so the two agent options are read through a single handle.
Source§impl Service
impl Service
Sourcefn check_remote_addr(&self, response: &Response) -> Result
fn check_remote_addr(&self, response: &Response) -> Result
Screen a preview response’s peer address against the CIDR denylist.
A missing peer address cannot be screened, so it fails closed.
Source§impl Service
impl Service
Sourceasync fn oembed_recover(
&self,
url: &Url,
data: UrlPreviewData,
) -> UrlPreviewData
async fn oembed_recover( &self, url: &Url, data: UrlPreviewData, ) -> UrlPreviewData
Recover a preview from the origin’s oEmbed endpoint when the page yielded nothing usable.
Some origins serve their <head> metadata only to an agent they
recognise as a link-preview crawler, while answering oEmbed for anyone.
A page that parsed to nothing is therefore worth one much smaller second
request, and the original preview stands if that request fails too.
Source§impl Service
impl Service
Sourceasync fn oembed_preview(
&self,
endpoint: &Url,
page: &Url,
) -> Result<UrlPreviewData>
async fn oembed_preview( &self, endpoint: &Url, page: &Url, ) -> Result<UrlPreviewData>
Fetch an oEmbed document and render it as a preview.
The document names a thumbnail rather than carrying one, so the image is
measured and staged through the same path an og:image takes.
Source§impl Service
impl Service
Sourceasync fn oembed_image(&self, thumbnail_url: Option<&str>) -> UrlPreviewData
async fn oembed_image(&self, thumbnail_url: Option<&str>) -> UrlPreviewData
Measure an oEmbed thumbnail, yielding an empty preview when it is absent or unusable.
A thumbnail failure must not cost the textual preview the document has already provided.
Source§impl Service
impl Service
Sourceasync fn preview_image(&self, image_url: &Url) -> Result<UrlPreviewData>
async fn preview_image(&self, image_url: &Url) -> Result<UrlPreviewData>
Fetch and measure a preview image, keeping the textual preview when the origin refuses it.
The measurement is a media fetch: it carries the media agent, or the origin could serve the measurement different content than it serves the relayed mxc.
Source§impl Service
impl Service
Sourcepub async fn download_image(&self, response: Response) -> Result<UrlPreviewData>
pub async fn download_image(&self, response: Response) -> Result<UrlPreviewData>
Download an image for URL preview metadata.
When URL previews are enabled, the image is staged for lazy media retrieval; otherwise this returns the feature-disabled error.
Source§impl Service
impl Service
Sourceasync fn media_response(&self, url: &Url) -> Result<Response>
async fn media_response(&self, url: &Url) -> Result<Response>
Fetch a URL with the media client, applying the same address and status screening as the page fetch. Direct preview media is measured and registered from the media client’s response so it matches what the relay will serve.
Source§impl Service
impl Service
Sourceasync fn media_refetch(
&self,
url: &Url,
response: Response,
via_media_client: bool,
) -> Result<Response>
async fn media_refetch( &self, url: &Url, response: Response, via_media_client: bool, ) -> Result<Response>
Replace a page-client response with the media client’s for a direct media URL. When no distinct media agent is configured the two clients are identical and the original response is used as-is, avoiding a second request.
Source§impl Service
impl Service
Sourcefn register_lazy_media(&self, url: &str) -> String
fn register_lazy_media(&self, url: &str) -> String
Mint a local mxc:// URI that resolves to url on first download (see
Service::fetch_lazy_media), keeping preview generation independent of the
underlying file size while routing clients through this server.
Source§impl Service
impl Service
pub async fn download_video(&self, response: Response) -> Result<UrlPreviewData>
Source§impl Service
impl Service
pub async fn download_audio(&self, response: Response) -> Result<UrlPreviewData>
Source§impl Service
impl Service
async fn download_html( &self, url: &Url, response: Response, ) -> Result<UrlPreviewData>
Source§impl Service
impl Service
Sourcefn lazy_media(
&self,
page: &Url,
obj: &OpengraphObject,
class: &str,
) -> Option<String>
fn lazy_media( &self, page: &Url, obj: &OpengraphObject, class: &str, ) -> Option<String>
Mint an mxc:// URI for a page’s declared media, or nothing when it is not
relayable.
The URL is recorded rather than fetched, so a page naming a large video costs the preview request no bandwidth; it is fetched and checked only once a client asks for the resulting URI. Screening IP literals here as well keeps a preview from handing out a URI that the same check at relay time is guaranteed to refuse.
Source§impl Service
impl Service
async fn handle_thumbnail_file( &self, mxc: &Mxc<'_>, dim: &Dim, content: Content, ) -> Result<Media>
Source§impl Service
impl Service
async fn handle_content_file( &self, mxc: &Mxc<'_>, content: Content, ) -> Result<Media>
Source§impl Service
impl Service
async fn handle_location(&self, mxc: &Mxc<'_>, location: &str) -> Result<Media>
Source§impl Service
impl Service
pub async fn fetch_remote_thumbnail_legacy( &self, body: &Request, ) -> Result<Response>
Source§impl Service
impl Service
Sourcepub async fn upload_thumbnail(
&self,
mxc: &Mxc<'_>,
content_disposition: Option<&ContentDisposition>,
content_type: Option<&str>,
dim: &Dim,
file: &[u8],
) -> Result
pub async fn upload_thumbnail( &self, mxc: &Mxc<'_>, content_disposition: Option<&ContentDisposition>, content_type: Option<&str>, dim: &Dim, file: &[u8], ) -> Result
Uploads or replaces a file thumbnail.
pub async fn get_or_fetch_thumbnail( &self, mxc: &Mxc<'_>, dim: &Dim, timeout_ms: Duration, user: &UserId, ) -> Result<Media>
Sourcepub async fn get_thumbnail(
&self,
mxc: &Mxc<'_>,
dim: &Dim,
timeout_duration: Option<Duration>,
) -> Result<Media>
pub async fn get_thumbnail( &self, mxc: &Mxc<'_>, dim: &Dim, timeout_duration: Option<Duration>, ) -> Result<Media>
Download a thumbnail and wait up to a timeout_ms if it is pending.
Sourcepub async fn get_stored_thumbnail(
&self,
mxc: &Mxc<'_>,
dim: &Dim,
) -> Result<Media>
pub async fn get_stored_thumbnail( &self, mxc: &Mxc<'_>, dim: &Dim, ) -> Result<Media>
Downloads a file’s thumbnail.
Here’s an example on how it works:
- Client requests an image with width=567, height=567
- Server rounds that up to (800, 600), so it doesn’t have to save too many thumbnails
- Server rounds that up again to (958, 600) to fix the aspect ratio (only for width,height>96)
- Server creates the thumbnail and sends it to the user
For width,height <= 96 the server uses another thumbnailing algorithm which crops the image afterwards.
Source§impl Service
impl Service
Sourceasync fn get_thumbnail_saved(&self, data: Metadata) -> Result<Media>
async fn get_thumbnail_saved(&self, data: Metadata) -> Result<Media>
Using saved thumbnail
Source§impl Service
impl Service
Sourcefn failed_recently(&self, mxc: &Mxc<'_>) -> bool
fn failed_recently(&self, mxc: &Mxc<'_>) -> bool
Whether this video failed within the cooldown, where trying again would spend a slot to reach the same failure.
Source§impl Service
impl Service
pub(super) fn remember_failure(&self, mxc: &Mxc<'_>)
Source§impl Service
impl Service
Sourcepub async fn create_pending(
&self,
mxc: &Mxc<'_>,
user: &UserId,
unused_expires_at: u64,
) -> Result
pub async fn create_pending( &self, mxc: &Mxc<'_>, user: &UserId, unused_expires_at: u64, ) -> Result
Create a pending media upload ID.
Sourcepub async fn upload_pending(
&self,
mxc: &Mxc<'_>,
user: &UserId,
content_disposition: Option<&ContentDisposition>,
content_type: Option<&str>,
file: &[u8],
) -> Result
pub async fn upload_pending( &self, mxc: &Mxc<'_>, user: &UserId, content_disposition: Option<&ContentDisposition>, content_type: Option<&str>, file: &[u8], ) -> Result
Uploads content to a pending media ID.
Sourcepub async fn create(
&self,
mxc: &Mxc<'_>,
user: Option<&UserId>,
content_disposition: Option<&ContentDisposition>,
content_type: Option<&str>,
file: &[u8],
) -> Result
pub async fn create( &self, mxc: &Mxc<'_>, user: Option<&UserId>, content_disposition: Option<&ContentDisposition>, content_type: Option<&str>, file: &[u8], ) -> Result
Uploads a file.
Sourcepub async fn delete(&self, mxc: &Mxc<'_>) -> Result
pub async fn delete(&self, mxc: &Mxc<'_>) -> Result
Deletes a file in the database and from the media directory via an MXC
Sourcepub async fn delete_from_user(&self, user: &UserId) -> Result<usize>
pub async fn delete_from_user(&self, user: &UserId) -> Result<usize>
Deletes all media by the specified user
currently, this is only practical for local users
Sourcepub async fn get_or_fetch(
&self,
mxc: &Mxc<'_>,
timeout_ms: Duration,
) -> Result<Media>
pub async fn get_or_fetch( &self, mxc: &Mxc<'_>, timeout_ms: Duration, ) -> Result<Media>
Get file from local storage or make a federation request if it originates remotely.
Sourcepub async fn get(
&self,
mxc: &Mxc<'_>,
timeout: Option<Duration>,
) -> Result<Media>
pub async fn get( &self, mxc: &Mxc<'_>, timeout: Option<Duration>, ) -> Result<Media>
Get file from local storage while waiting up to a timeout_ms if it is pending.
Sourcepub async fn get_stored(&self, mxc: &Mxc<'_>) -> Result<Media>
pub async fn get_stored(&self, mxc: &Mxc<'_>) -> Result<Media>
Get file from local storage.
Sourceasync fn fetch_lazy_media(&self, mxc: &Mxc<'_>) -> Result<Media>
async fn fetch_lazy_media(&self, mxc: &Mxc<'_>) -> Result<Media>
Resolve lazy URL-preview media on first download, promoting the staged or freshly-fetched bytes into the media store so the origin is fetched at most once per item.
Sourcepub async fn redirect_url(
&self,
mxc: &Mxc<'_>,
dim: &Dim,
) -> Result<Option<Url>>
pub async fn redirect_url( &self, mxc: &Mxc<'_>, dim: &Dim, ) -> Result<Option<Url>>
Presigned redirect URL for locally-stored media (MSC3860).
Returns the first configured provider’s signed URL for the object, or
None when redirects are disabled, the media is unknown, or no provider
can presign (filesystem-only media).
Sourcepub async fn get_all_mxcs(&self) -> Result<Vec<OwnedMxcUri>>
pub async fn get_all_mxcs(&self) -> Result<Vec<OwnedMxcUri>>
Gets all the MXC URIs in our media database
Sourcepub async fn user_media(&self, user: &UserId) -> Result<Vec<UserMediaEntry>>
pub async fn user_media(&self, user: &UserId) -> Result<Vec<UserMediaEntry>>
Every media item uploaded by a local user, carrying the fields tuwunel can derive: content type, upload name, byte length and modification time from storage-provider object metadata. Untracked columns (last-access, quarantine, url-cache) are not represented.
Sourcepub async fn media_entry(&self, mxc: &Mxc<'_>) -> Option<UserMediaEntry>
pub async fn media_entry(&self, mxc: &Mxc<'_>) -> Option<UserMediaEntry>
Derivable metadata for the single media item at the given MXC, with the uploading local user resolved from the uploader index when present.
async fn user_media_entry( &self, user: Option<&UserId>, mxc: OwnedMxcUri, ) -> Option<UserMediaEntry>
Sourcepub fn upload_stats(&self) -> impl Stream<Item = UploadStat> + Send + '_
pub fn upload_stats(&self) -> impl Stream<Item = UploadStat> + Send + '_
Uploader, byte length and storage modification time of every media item uploaded by a local user, one row per upload; media missing from every storage provider are skipped.
Sourcepub async fn delete_by_date_size(
&self,
before_ts: u64,
size_gt: u64,
keep_profiles: bool,
) -> Result<Vec<OwnedMxcUri>>
pub async fn delete_by_date_size( &self, before_ts: u64, size_gt: u64, keep_profiles: bool, ) -> Result<Vec<OwnedMxcUri>>
Deletes local media older than before_ts (by storage-provider mtime)
and strictly larger than size_gt bytes, sparing profile and
room-avatar media when keep_profiles. Returns the deleted MXCs, empty
when none match. Quarantine and protection flags are not tracked, so no
media is spared on those grounds.
Sourceasync fn avatar_mxcs(&self) -> HashSet<OwnedMxcUri>
async fn avatar_mxcs(&self) -> HashSet<OwnedMxcUri>
The MXCs of every local user’s profile avatar and every room’s avatar,
the spare-set honoured by keep_profiles.
fn is_local(&self, mxc: &OwnedMxcUri) -> bool
Sourceasync fn head_meta(&self, key: &[u8]) -> Option<ObjectMeta>
async fn head_meta(&self, key: &[u8]) -> Option<ObjectMeta>
First storage provider’s object metadata for the media stored under
key (byte length and modification time), or None when no provider
holds it.
Sourcepub async fn delete_range(
&self,
time: SystemTime,
older_than: bool,
newer_than: bool,
yes_i_want_to_delete_local_media: bool,
) -> Result<usize>
pub async fn delete_range( &self, time: SystemTime, older_than: bool, newer_than: bool, yes_i_want_to_delete_local_media: bool, ) -> Result<usize>
Deletes all media files before or after the given time. Returns a usize with the number of media files deleted.
pub async fn create_media_dir(&self) -> Result
async fn remove_media_file(&self, key: &[u8]) -> Result
async fn create_media_file(&self, key: &[u8], file: &[u8]) -> Result
fn storage_providers(&self) -> impl Iterator<Item = &Arc<Provider>> + Send + '_
pub async fn get_metadata(&self, mxc: &Mxc<'_>) -> Option<Metadata>
pub fn get_media_path_sha256(&self, key: &[u8]) -> PathBuf
Sourcepub fn get_media_name_sha256(&self, key: &[u8]) -> String
pub fn get_media_name_sha256(&self, key: &[u8]) -> String
new SHA256 file name media function. requires database migrated. uses SHA256 hash of the base64 key as the file name
Sourcepub fn get_media_path_b64(&self, key: &[u8]) -> PathBuf
pub fn get_media_path_b64(&self, key: &[u8]) -> PathBuf
old base64 file name media function
This is the old version of get_media_path_sha256 that uses the full
base64 key as the filename.
pub fn get_media_dir(&self) -> PathBuf
Trait Implementations§
Source§impl Service for Service
impl Service for Service
Source§fn build(args: &Args<'_>) -> Result<Arc<Self>>
fn build(args: &Args<'_>) -> Result<Arc<Self>>
Source§fn name(&self) -> &str
fn name(&self) -> &str
crate::service::make_name(std::module_path!())Source§fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
fn worker<'async_trait>(
self: Arc<Self>,
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
Source§fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn interrupt<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn clear_cache<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn memory_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
_out: &'life1 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn memory_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
_out: &'life1 mut (dyn Write + Send),
) -> Pin<Box<dyn Future<Output = Result> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn unconstrained(&self) -> bool
fn unconstrained(&self) -> bool
Auto Trait Implementations§
impl !Freeze for Service
impl !RefUnwindSafe for Service
impl !UnwindSafe for Service
impl Send for Service
impl Sync for Service
impl Unpin for Service
impl UnsafeUnpin for Service
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> ExpectInto for T
impl<T> ExpectInto for T
Source§impl<T> Expected for T
impl<T> Expected for T
Source§fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
fn expected_add(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedAdd,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
fn expected_sub(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedSub,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
fn expected_mul(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedMul,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
fn expected_div(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedDiv,
rhs with an expectation that the operation is valid. Read moreSource§fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
fn expected_rem(self, rhs: Self) -> Selfwhere
Self: Sized + CheckedRem,
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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 moreimpl<T> JsonCastable<CanonicalJsonValue> for T
impl<T> JsonCastable<Value> for T
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
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();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
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();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
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();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
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();§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.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
§fn whenever(&self, value: Condition) -> Painted<&T>
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);§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
fn add_extension<T>(self, value: T) -> AddExtension<Self, T>where
Self: Sized,
§fn compression(self) -> Compression<Self>where
Self: Sized,
fn compression(self) -> Compression<Self>where
Self: Sized,
§fn decompression(self) -> Decompression<Self>where
Self: Sized,
fn decompression(self) -> Decompression<Self>where
Self: Sized,
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
fn sensitive_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>where
Self: Sized,
§fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
fn sensitive_request_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveRequestHeaders<Self>where
Self: Sized,
§fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
fn sensitive_response_headers(
self,
headers: impl IntoIterator<Item = HeaderName>,
) -> SetSensitiveResponseHeaders<Self>where
Self: Sized,
§fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn override_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn append_request_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
fn insert_request_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetRequestHeader<Self, M>where
Self: Sized,
§fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn override_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn append_response_header<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
fn insert_response_header_if_not_present<M>(
self,
header_name: HeaderName,
make: M,
) -> SetResponseHeader<Self, M>where
Self: Sized,
§fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>where
Self: Sized,
500 Internal Server responses. Read moreSource§impl<T> Tried for T
impl<T> Tried for T
Source§fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
fn try_add(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedAdd,
rhs with checked arithmetic. Read moreSource§fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
fn try_sub(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedSub,
rhs with checked arithmetic. Read moreSource§fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
fn try_mul(self, rhs: Self) -> Result<Self, Error>where
Self: Sized + CheckedMul,
rhs with checked arithmetic. Read more