Skip to main content

Config

Struct Config 

Source
pub struct Config {
Show 50 fields pub rocksdb: Rocksdb, pub server_name: OwnedServerName, pub database_path: PathBuf, pub tls: TlsConfig, pub database_restore_backup: Option<u32>, pub well_known: WellKnownConfig, pub proxy: ProxyConfig, pub rate_limiting: RateLimits, pub test: BTreeSet<String>, pub maintenance: bool, pub listening: bool, pub appservice_dir: Option<PathBuf>, pub database_migrations: bool, pub force_migration: bool, pub storage_provider: BTreeMap<String, StorageProvider>, pub registration_terms: BTreeMap<String, TermsPolicy>, pub ldap: LdapConfig, pub jwt: JwtConfig, pub smtp: SmtpConfig, pub appservice: BTreeMap<String, AppService>, pub identity_provider: BTreeMap<String, IdentityProvider>, catchall: BTreeMap<String, IgnoredAny>, pub cache: Cache, pub database: Database, pub runtime: Runtime, pub http: Http, pub network: Network, pub media: Media, pub federation: Federation, pub rooms: Rooms, pub sending: Sending, pub authentication: Authentication, pub directory: Directory, pub encryption: Encryption, pub profile: Profile, pub registration: Registration, pub admin: Admin, pub appservice_client: AppserviceClient, pub client: Client, pub compatibility: Compatibility, pub configuration: Configuration, pub logging: Logging, pub presence: Presence, pub push: Push, pub read_receipts: ReadReceipts, pub rendezvous: Rendezvous, pub telemetry: Telemetry, pub tracing: Tracing, pub turn: Turn, pub typing: Typing,
}
Expand description

Global settings

Every setting lives under [global]. The first keys below name the server and its storage; each [global.<name>] section further down is optional and keeps its defaults when left out.

Before the first start, set server_name and check database_path. The first start records server_name in the database, and a database recorded under another name is refused, so changing the name later means starting over with an empty database. database_path holds the database and, by default, uploaded media.

Tips:

  • No config file is read by default. Name one with TUWUNEL_CONFIG (or CONDUWUIT_CONFIG, CONDUIT_CONFIG) or with -c/--config, which is repeatable and loads after it; later files win. A file that mixes bare keys with a [global] header is refused.
  • Environment variables override files: TUWUNEL_ plus the key path with __ between levels, so database.backup.path becomes TUWUNEL_DATABASE__BACKUP__PATH. -O key=value overrides both.
  • Keys marked reloadable: yes apply on SIGUSR1 or !admin server reload-config; others may need a restart. A reload that changes server_name fails.
  • Misspelled keys are ignored, not rejected; most log a warning, and configuration.error_on_unknown_opts = true makes that fatal.

Fields§

§rocksdb: Rocksdb

RocksDB engine settings.

display: section

§server_name: OwnedServerName

The server_name is the pretty name of this server. It is used as a suffix for user and room IDs/aliases.

See the docs for reverse proxying and delegation: https://tuwunel.chat/deploying/generic.html#setting-up-the-reverse-proxy

Also see the [global.well_known] config section at the very bottom.

Examples of delegation:

  • https://matrix.org/.well-known/matrix/server
  • https://matrix.org/.well-known/matrix/client

YOU NEED TO EDIT THIS. THIS CANNOT BE CHANGED AFTER WITHOUT A DATABASE WIPE.

example: “girlboss.ceo”

§database_path: PathBuf

This is the only directory where tuwunel will save its data, including media. Note: this was previously “/var/lib/matrix-conduit”.

default: “/var/lib/tuwunel”

§tls: TlsConfig

Configures direct TLS listeners.

Values are read from the separate [global.tls] section. Certificate and key paths must be supplied together before TLS is enabled.

§database_restore_backup: Option<u32>

Restore this online database backup on startup, before the database is opened. The value is a backup ID as listed by !admin server list-backups, or 0 for the most recent backup. Set by the --restore-backup command line argument, and refused from a configuration file, where it would repeat the restore on every startup.

§well_known: WellKnownConfig

Configures Matrix discovery documents and related endpoints.

Values are read from the separate [global.well_known] section. Client, server, support, and MatrixRTC responses consume these settings.

§proxy: ProxyConfig

Examples:

  • No proxy (default):

    proxy = "none"
  • For global proxy, create the section at the bottom of this file:

    [global.proxy]
    global = { url = "socks5h://localhost:9050" }
  • To proxy some domains:

    [global.proxy]
    [[global.proxy.by_domain]]
    url = "socks5h://localhost:9050"
    include = ["*.onion", "matrix.myspecial.onion"]
    exclude = ["*.myspecial.onion"]

Include vs. Exclude:

  • If include is an empty list, it is assumed to be ["*"].

  • If a domain matches both the exclude and include list, the proxy will only be used if it was included because of a more specific rule than it was excluded. In the above example, the proxy would be used for ordinary.onion, matrix.myspecial.onion, but not hello.myspecial.onion.

default: “none”

§rate_limiting: RateLimits

Configures request rate limits, one [global.rate_limiting] subsection per kind of request.

§test: BTreeSet<String>

Arbitrary argument vector for integration testing. Functionality in the server is altered or informed for the requirements of integration tests.

  • “smoke” performs a shutdown after startup admin commands rather than hanging on client handling.

display: hidden

§maintenance: bool

Indicates the server has started in maintenance mode. Historically maintenance mode has been enabled by the command line argument --maintenance which then sets various configuration items such as listening=false among others. That is still the case. This option was only added as a single source of truth that --maintenance mode is active.

This option must never be set manually.

display: hidden

§listening: bool

Enables listener sockets; can be set to false to disable listening. This option is intended for developer/diagnostic purposes only.

§appservice_dir: Option<PathBuf>

Directory containing appservice yaml registration files.

default: “”

§database_migrations: bool

Apply pending database migrations on startup. This option is intended for developer debugging and testing only. Never set this option to false unless you have been instructed to do so. Setting this option to false may cause permanent damage and permanent loss of data.

Any new database migrations will not be applied on startup, and the database schema version will not be adjusted. These migrations and schema changes may be expected by the current codebase but may not be available when this option is set to false.

Setting this option to false is accepted only after the required local state memo invalidation has run once. Start once with this option true if startup reports that prerequisite missing. With the marker present, false continues to skip migrations as configured.

§force_migration: bool

Open a database whose schema version is newer than this build supports.

A database reporting a higher schema version than this build is normally refused, since opening it stamps the schema down to this build’s version and may permanently lose data written by the newer build. Setting this to true overrides that refusal: the database opens, one-time migrations run, and the schema is stamped down to this build’s version.

It has no effect when the discovered version is at or below this build’s version, where migrations apply normally either way. It is also not needed to import a Conduit database or a fork of conduwuit; those are recognized by lineage and open without it.

This option is extremely dangerous and intended for developer debugging and testing only. Never set it unless you have been instructed to do so; it may cause permanent damage and permanent loss of data.

§storage_provider: BTreeMap<String, StorageProvider>

Defines named media storage providers.

Each map key names a provider, and each value selects a local or S3-compatible backend or disables the entry. Provider-specific settings live in separate sections.

§registration_terms: BTreeMap<String, TermsPolicy>

Defines policy documents users must accept during registration.

Each map key is the policy identifier exposed in the m.login.terms UIA stage. An empty map leaves the terms stage disabled.

§ldap: LdapConfig

Configures LDAP login integration.

Connection, bind, search, and attribute settings live in the separate [global.ldap] section. LDAP authentication is disabled by default.

§jwt: JwtConfig

Configures JSON Web Token login integration.

Key format, algorithm, claim validation, and user provisioning settings live in [global.jwt]. Token login is disabled by default.

§smtp: SmtpConfig

Configures outbound SMTP email delivery.

Providing a connection URI enables the email subsystem. Registration flags determine when a verified address is required.

§appservice: BTreeMap<String, AppService>

Defines inline application service registrations.

Each map key names one registration and supplies its default identifier. The contained settings are converted to Matrix application service data.

§identity_provider: BTreeMap<String, IdentityProvider>

Defines OpenID Connect identity provider registrations.

Each entry configures client credentials, discovery, and account mapping. Its stable client_id identifies the provider while brand selects provider-specific defaults and workarounds.

§catchall: BTreeMap<String, IgnoredAny>§cache: Cache

Settings for cache.

display: section

§database: Database

Settings for database.

display: section

§runtime: Runtime

Settings for runtime.

display: section

§http: Http

Settings for http.

display: section

§network: Network

Settings for network.

display: section

§media: Media

Settings for media.

display: section

§federation: Federation

Settings for federation.

display: section

§rooms: Rooms

Settings for rooms.

display: section

§sending: Sending

Settings for sending.

display: section

§authentication: Authentication

Settings for authentication.

display: section

§directory: Directory

Settings for directory.

display: section

§encryption: Encryption

Settings for encryption.

display: section

§profile: Profile

Settings for profile.

display: section

§registration: Registration

Settings for registration.

display: section

§admin: Admin

Settings for admin.

display: section

§appservice_client: AppserviceClient

Settings for appservice client.

display: section

§client: Client

Settings for client.

display: section

§compatibility: Compatibility

Settings for compatibility.

display: section

§configuration: Configuration

Settings for configuration.

display: section

§logging: Logging

Settings for logging.

display: section

§presence: Presence

Settings for presence.

display: section

§push: Push

Settings for push.

display: section

§read_receipts: ReadReceipts

Settings for read receipts.

display: section

§rendezvous: Rendezvous

Settings for rendezvous.

display: section

§telemetry: Telemetry

Settings for telemetry.

display: section

§tracing: Tracing

Settings for tracing.

display: section

§turn: Turn

Settings for turn.

display: section

§typing: Typing

Settings for typing.

display: section

Implementations§

Source§

impl Config

Source

pub fn get_unix_socket_perms(&self) -> Result<u32>

Interprets the configured Unix socket permission digits as an octal mode.

The returned value is suitable for applying to a newly created socket. An invalid octal digit produces a configuration error.

Source§

impl Config

Source

pub fn get_bind_addrs(&self) -> Vec<SocketAddr>

Builds every configured TCP listener address.

The result is the Cartesian product of the configured hosts and ports. When neither TCP addresses nor a Unix socket are configured, loopback hosts apply.

Source§

impl Config

Source§

impl Config

Source§

impl Config

Source

pub fn is_address_defaulted(&self) -> bool

Whether the addresses to bind come from the built-in default rather than the http.listen.address option.

The default is a guess that both loopback families exist on the host, so one of them failing to bind is tolerable where a configured address is not.

Source§

impl Config

Source

pub fn require_federation(&self) -> Result

Refuses a request that needs federation while federation is disabled.

Inbound and outbound requests fail with the same 403 M_FORBIDDEN, since the refusal enforces the operator’s setting rather than reporting a fault.

Source§

impl Config

Source

pub fn require_remote_permitted(&self, server_name: &ServerName) -> Result

Refuses federation with a remote server while federation is disabled or the configuration forbids that server.

The forbidden-server check always permits the local server name. Either refusal fails with the same 403 M_FORBIDDEN for inbound and outbound requests.

Source§

impl Config

Source

pub fn is_remote_permitted(&self, server_name: &ServerName) -> bool

Determines whether federation with a remote server is allowed.

require_remote_permitted wraps this check; call this directly where refusals are too frequent to build an error each time.

Source§

impl Config

Source

pub fn is_forbidden_remote_server_name(&self, server_name: &ServerName) -> bool

Determines whether a remote server name is forbidden.

The local server name is always permitted. Otherwise a deny-list match or an active allow-list miss forbids the destination.

Source§

impl Config

Source

pub fn require_supported_room_version(&self, version: &RoomVersionId) -> Result

Refuses a room version this configuration does not enable.

The refusal is M_INCOMPATIBLE_ROOM_VERSION, whose room_version field names the refused version for the client or remote server.

Source§

impl Config

Source

pub fn supported_room_version(&self, version: &RoomVersionId) -> bool

Reports whether a room version is enabled by this configuration.

Stable versions are always enabled. Unstable and experimental versions are included only when their respective configuration flags permit them.

Source

pub fn supported_room_versions( &self, ) -> impl Iterator<Item = (RoomVersionId, RoomVersionStability)> + '_

Iterates over the room versions enabled by this configuration.

Stable versions appear first, followed by permitted unstable and experimental versions. Experimental entries are advertised as unstable.

Source§

impl Config

Source

pub fn login_terms_params(&self) -> Option<LoginTermsParams>

Builds registration terms parameters from configured policy documents.

Policy identifiers and language keys are preserved in the Matrix UIA shape. An empty policy map returns None and does not require a terms stage.

Source§

impl Config

Source

pub(crate) fn fmt_config(&self, out: &mut Formatter<'_>) -> Result

Source§

impl Config

Source

pub fn load<'a, I>(paths: I) -> Result<Figment>
where I: Iterator<Item = &'a Path>,

Loads raw configuration from ordered file and environment sources.

Explicit paths follow config files selected through the supported environment variables, and later files override earlier files. Config values from the three environment namespaces take precedence over files.

Source§

impl Config

Source

pub(crate) fn file_paths<'a, I>(paths: I) -> impl Iterator<Item = PathBuf>
where I: Iterator<Item = &'a Path>,

Source§

impl Config

Source

pub(crate) fn load_files<I, P>(paths: I) -> Result<Figment>
where I: Iterator<Item = P>, P: Into<PathBuf>,

Source§

impl Config

Source§

impl Config

Source

pub fn normalize<P: Provider>(provider: P) -> Result<impl Provider>

Normalizes one configuration source before it is combined with others.

Legacy paths retain source metadata and follow the same precedence as canonical paths. Conflicting spellings within one source are rejected. The returned provider supplies its snapshot to one combination operation.

Source§

impl Config

Source

pub(crate) fn merge_environment(config: Figment) -> Result<Figment>

Source§

impl Config

Source

pub fn new(raw_config: &Figment) -> Result<Self>

Extracts the typed configuration from the merged raw sources.

A rejection is reported against the configuration file when one was loaded. With none loaded, the field detail is followed by a note that no file was selected, naming --config and TUWUNEL_CONFIG. Keys the schema does not know are recorded in catchall.

Source

pub fn check(&self) -> Result

Validates the complete configuration.

The startup checks emit warnings for deprecated or risky settings and reject invalid combinations. Reload-specific comparisons are performed by the configuration manager separately.

Source§

impl Config

Source

pub fn password_hash_cost(&self) -> Cost

Argon2id cost parameters for hashing a new password.

The three settings are interdependent, so they travel as a unit rather than being read one at a time. Verification never consults them: the cost of checking a password comes from the stored hash.

Source§

impl Config

Source

pub fn lists_identity_providers(&self) -> bool

Returns whether login screens list each identity provider by name.

authentication.login.single_sso and authentication.login.sso_custom_providers_page each replace that list with one single sign-on entry.

Source§

impl Config

Source

pub fn allows_password_registration(&self) -> bool

Returns whether new accounts may be registered with a password.

Password registration needs both registration.enable and authentication.login.with_password, since a password account on a server refusing password login could never sign in again. Registration through an identity provider follows that provider’s own registration option instead.

Source§

impl Config

Source

pub fn storage_provider_sections( &self, ) -> impl Iterator<Item = ProviderSection<'_>>

Lists the storage provider sections the storage service builds from.

These are the configured sections plus the built-in local media provider, which keeps media in the media directory under database_path and is left out when a media section replaces it.

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'de> Deserialize<'de> for Config

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Config

Source§

fn fmt(&self, out: &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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> DropFlavorWrapper<T> for T

§

type Flavor = MayDrop

The DropFlavor that [wrap]s T into Self
Source§

impl<T> ExpectInto for T

Source§

fn expect_into<Dst: TryFrom<Self>>(self) -> Dst
where Self: Sized,

Converts the value into Dst and returns the successful result. Read more
Source§

impl<T> Expected for T

Source§

fn expected_add(self, rhs: Self) -> Self
where Self: CheckedAdd + Sized,

Adds rhs with an expectation that the operation is valid. Read more
Source§

fn expected_sub(self, rhs: Self) -> Self
where Self: CheckedSub + Sized,

Subtracts rhs with an expectation that the operation is valid. Read more
Source§

fn expected_mul(self, rhs: Self) -> Self
where Self: CheckedMul + Sized,

Multiplies by rhs with an expectation that the operation is valid. Read more
Source§

fn expected_div(self, rhs: Self) -> Self
where Self: CheckedDiv + Sized,

Divides by rhs with an expectation that the operation is valid. Read more
Source§

fn expected_rem(self, rhs: Self) -> Self
where Self: CheckedRem + Sized,

Computes the remainder with an expectation that the operation is valid. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T, W> HasTypeWitness<W> for T
where W: MakeTypeWitness<Arg = T>, T: ?Sized,

§

const WITNESS: W = W::MAKE

A constant of the type witness
§

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

§

const TYPE_EQ: TypeEq<T, <T as Identity>::Type> = TypeEq::NEW

Proof that Self is the same type as Self::Type, provides methods for casting between Self and Self::Type.
§

type Type = T

The same type as Self, used to emulate type equality bounds (T == U) with associated type equality constraints (T: Identity<Type = U>).
§

impl<T> Instrument for T

§

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

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

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
§

impl<T> JsonCastable<CanonicalJsonValue> for T

§

impl<T> JsonCastable<Value> for T

§

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

§

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 primary(&self) -> Painted<&T>

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

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

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

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

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

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));
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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>

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

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

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

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

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

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));
§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 bold(&self) -> Painted<&T>

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

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

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

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

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

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

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

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

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());
§

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

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

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

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

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

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

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

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

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

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 mask(&self) -> Painted<&T>

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

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

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

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

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

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

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

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

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());
§

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

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

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

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

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

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

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

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

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

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);
§

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

Create a new [Painted] with a default [Style]. Read more
§

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
§

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

§

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
§

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
§

impl<T> ServiceExt for T

§

fn add_extension<T>(self, value: T) -> AddExtension<Self, T>
where Self: Sized,

Add some shareable value to request extensions. Read more
§

fn compression(self) -> Compression<Self>
where Self: Sized,

Compresses response bodies. Read more
§

fn decompression(self) -> Decompression<Self>
where Self: Sized,

Decompress response bodies. Read more
§

fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using HTTP status codes. Read more
§

fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>
where Self: Sized,

High level tracing that classifies responses using gRPC headers. Read more
§

fn follow_redirects(self) -> FollowRedirect<Self>
where Self: Sized,

Follow redirect resposes using the Standard policy. Read more
§

fn sensitive_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<SetSensitiveResponseHeaders<Self>>
where Self: Sized,

Mark headers as sensitive on both requests and responses. Read more
§

fn sensitive_request_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveRequestHeaders<Self>
where Self: Sized,

Mark headers as sensitive on requests. Read more
§

fn sensitive_response_headers( self, headers: impl IntoIterator<Item = HeaderName>, ) -> SetSensitiveResponseHeaders<Self>
where Self: Sized,

Mark headers as sensitive on responses. Read more
§

fn override_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request. Read more
§

fn append_request_header<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Append a header into the request. Read more
§

fn insert_request_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetRequestHeader<Self, M>
where Self: Sized,

Insert a header into the request, if the header is not already present. Read more
§

fn override_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response. Read more
§

fn append_response_header<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Append a header into the response. Read more
§

fn insert_response_header_if_not_present<M>( self, header_name: HeaderName, make: M, ) -> SetResponseHeader<Self, M>
where Self: Sized,

Insert a header into the response, if the header is not already present. Read more
§

fn catch_panic(self) -> CatchPanic<Self, DefaultResponseForPanic>
where Self: Sized,

Catch panics and convert them into 500 Internal Server responses. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> Tried for T

Source§

fn try_add(self, rhs: Self) -> Result<Self>
where Self: CheckedAdd + Sized,

Adds rhs with checked arithmetic. Read more
Source§

fn try_sub(self, rhs: Self) -> Result<Self>
where Self: CheckedSub + Sized,

Subtracts rhs with checked arithmetic. Read more
Source§

fn try_mul(self, rhs: Self) -> Result<Self>
where Self: CheckedMul + Sized,

Multiplies by rhs with checked arithmetic. Read more
Source§

fn try_div(self, rhs: Self) -> Result<Self>
where Self: CheckedDiv + Sized,

Divides by rhs with checked arithmetic. Read more
Source§

fn try_rem(self, rhs: Self) -> Result<Self>
where Self: CheckedRem + Sized,

Computes the remainder by rhs with checked arithmetic. Read more
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.
§

impl<T> WithSubscriber for T

§

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
§

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

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