Struct Stage

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

Entrypoint for staging data on the GPU and interacting with lighting.

§Design

The Stage struct serves as the central hub for managing and staging data on the GPU. It provides a consistent API for creating resources, applying effects, and customizing parameters.

The Stage uses a combination of new_*, with_*, set_*, and getter functions to facilitate resource management and customization.

Resources are managed internally, requiring no additional lifecycle work from the user. This design simplifies the process of resource management, allowing developers to focus on creating and rendering their scenes without worrying about the underlying GPU resource management.

§Resources

The Stage is responsible for creating various resources and staging them on the GPU. It handles the setup and management of the following resources:

§Lighting effects

The Stage also manages various lighting effects, which enhance the visual quality of the scene:

  • AnalyticalLight: Simulates a single light source, with three flavors:
    • DirectionalLight: Represents sunlight or other distant light sources.
    • PointLight: Represents a light source that emits light in all directions from a single point.
    • SpotLight: Represents a light source that emits light in a cone shape.
  • Skybox: Provides image-based lighting (IBL) for realistic environmental reflections and ambient lighting.
  • Bloom: Adds a glow effect to bright areas of the scene, enhancing visual appeal.
  • ShadowMap: Manages shadow mapping for realistic shadow rendering.
  • LightTiling: Optimizes lighting calculations by dividing the scene into tiles for efficient processing.

§Note

Clones of Stage all point to the same underlying data.

Implementations§

Source§

impl Stage

GLTF functions

Source§

impl Stage

Geometry functions

Source

pub fn default_vertices(&self) -> &Vertices

Returns the vertices of a white unit cube.

This is the mesh of every Primitive that has not had its vertices set.

Source

pub fn new_camera(&self) -> Camera

Stage a new Camera on the GPU.

If no camera is currently in use on the Stage through Stage::use_camera, this new camera will be used automatically.

Source

pub fn use_camera(&self, camera: impl AsRef<Camera>)

Use the given camera when rendering.

Source

pub fn used_camera_id(&self) -> Id<CameraDescriptor>

Return the Id of the camera currently in use.

Source

pub fn use_camera_id(&self, camera_id: Id<CameraDescriptor>)

Set the default camera Id.

Source

pub fn new_transform(&self) -> Transform

Stage a Transform on the GPU.

Source

pub fn new_vertices(&self, data: impl IntoIterator<Item = Vertex>) -> Vertices

Stage some vertex geometry data.

Source

pub fn new_indices(&self, data: impl IntoIterator<Item = u32>) -> Indices

Stage some vertex index data.

Source

pub fn new_morph_targets( &self, data: impl IntoIterator<Item = Vec<MorphTarget>>, ) -> MorphTargets

Stage new morph targets.

Source

pub fn new_morph_target_weights( &self, data: impl IntoIterator<Item = f32>, ) -> MorphTargetWeights

Stage new morph target weights.

Source

pub fn new_skin( &self, joints: impl IntoIterator<Item = impl Into<SkinJoint>>, inverse_bind_matrices: impl IntoIterator<Item = impl Into<Mat4>>, ) -> Skin

Stage a new skin.

Source

pub fn new_primitive(&self) -> Primitive

Stage a new Primitive on the GPU.

The returned Primitive will automatically be added to this Stage.

The returned Primitive will have the stage’s default Vertices, which is an all-white unit cube.

The returned Primitive uses the stage’s default Material, which is white and does not participate in lighting. To change this, first create a Material with Stage::new_material and then call Primitive::set_material with the new material.

Source

pub fn geometry_descriptor(&self) -> &Hybrid<GeometryDescriptor>

Returns a reference to the descriptor stored at the root of the geometry slab.

Source§

impl Stage

Materials methods.

Source

pub fn default_material(&self) -> &Material

Returns the default Material.

The default is an all-white matte material.

Source

pub fn new_material(&self) -> Material

Stage a new Material on the GPU.

The returned Material can be customized using the builder pattern.

Source

pub fn set_atlas_size(&self, size: Extent3d) -> Result<(), StageError>

Set the size of the atlas.

This will cause a repacking.

Source

pub fn add_images( &self, images: impl IntoIterator<Item = impl Into<AtlasImage>>, ) -> Result<Vec<AtlasTexture>, StageError>

Add images to the set of atlas images.

This returns a vector of Hybrid<AtlasTexture>, which is a descriptor of each image on the GPU. Dropping these entries will invalidate those images and cause the atlas to be repacked, and any raw GPU references to the underlying AtlasTexture will also be invalidated.

Adding an image can be quite expensive, as it requires creating a new texture array for the atlas and repacking all previous images. For that reason it is good to batch images to reduce the number of calls.

Source

pub fn clear_images(&self) -> Result<(), StageError>

Clear all images from the atlas.

§WARNING

This invalidates any previously staged AtlasTextures.

Source

pub fn set_images( &self, images: impl IntoIterator<Item = impl Into<AtlasImage>>, ) -> Result<Vec<AtlasTexture>, StageError>

Set the images to use for the atlas.

Resets the atlas, packing it with the given images and returning a vector of the frames already staged.

§WARNING

This invalidates any previously staged AtlasTextures.

Source§

impl Stage

Lighting methods.

Source

pub fn new_directional_light(&self) -> AnalyticalLight<DirectionalLight>

Stage a new directional light.

Source

pub fn new_point_light(&self) -> AnalyticalLight<PointLight>

Stage a new point light.

Source

pub fn new_spot_light(&self) -> AnalyticalLight<SpotLight>

Stage a new spot light.

Source

pub fn add_light<T>(&self, bundle: &AnalyticalLight<T>)
where T: IsLight, Light: From<T>,

Add an AnalyticalLight to the internal list of lights.

This is called implicitly by Stage::new_*_light.

This can be used to add the light back to the scene after using Stage::remove_light.

Source

pub fn remove_light<T: IsLight>(&self, bundle: &AnalyticalLight<T>)

Remove an AnalyticalLight from the internal list of lights.

Use this to exclude a light from rendering, without dropping the light.

After calling this function you can include the light again using Stage::add_light.

Source

pub fn new_shadow_map<T>( &self, analytical_light: &AnalyticalLight<T>, size: UVec2, z_near: f32, z_far: f32, ) -> Result<ShadowMap, StageError>
where T: IsLight, Light: From<T>,

Enable shadow mapping for the given AnalyticalLight, creating a new ShadowMap.

§Tips for making a good shadow map
  1. Make sure the map is big enough. Using a big map can fix some peter panning issues, even before playing with bias in the returned ShadowMap. The bigger the map, the cleaner the shadows will be. This can also solve PCF problems.
  2. Don’t set PCF samples too high in the returned ShadowMap, as this can cause peter panning.
  3. Ensure the znear and zfar parameters make sense, as the shadow map uses these to determine how much of the scene to cover. If you find that shadows are cut off in a straight line, it’s likely znear or zfar needs adjustment.
Source

pub fn new_light_tiling(&self, config: LightTilingConfig) -> LightTiling

Enable light tiling, creating a new LightTiling.

Source§

impl Stage

Skybox methods

Source

pub fn use_skybox(&self, skybox: &Skybox) -> &Self

Used the given Skybox.

To remove the currently used Skybox, call [Skybox::remove_skybox].

Source

pub fn remove_skybox(&self) -> Option<Skybox>

Removes the currently used Skybox.

Returns the currently used Skybox, if any.

After calling this the Stage will not render with any Skybox, until [Skybox::use_skybox] is called with another Skybox.

Source

pub fn new_skybox_from_path( &self, path: impl AsRef<Path>, ) -> Result<Skybox, AtlasImageError>

Returns a new Skybox using the HDR image at the given path, if possible.

The returned Skybox must be used with Stage::use_skybox.

Source

pub fn new_skybox_from_bytes( &self, bytes: &[u8], ) -> Result<Skybox, AtlasImageError>

Returns a new Skybox using the bytes of an HDR image, if possible.

The returned Skybox must be used with Stage::use_skybox.

Source§

impl Stage

Image based lighting methods

Source

pub fn new_ibl(&self, skybox: &Skybox) -> Ibl

Crate a new Ibl from the given Skybox.

Source

pub fn use_ibl(&self, ibl: &Ibl) -> &Self

Use the given image based lighting.

Use Stage::new_ibl to create a new Ibl.

Source

pub fn remove_ibl(&self) -> Option<Ibl>

Remove the current image based lighting from the stage and return it, if any.

Source§

impl Stage

Source

pub fn runtime(&self) -> &WgpuRuntime

Returns the runtime.

Source

pub fn device(&self) -> &Device

Source

pub fn queue(&self) -> &Queue

Source

pub fn brdf_lut(&self) -> &BrdfLut

Returns a reference to the BrdfLut.

This is used for creating skyboxes used in image based lighting.

Source

pub fn used_gpu_buffer_byte_size(&self) -> usize

Sum the byte size of all used GPU memory.

Adds together the byte size of all underlying slab buffers.

§Note

This does not take into consideration staged data that has not yet been committed with either Stage::commit or Stage::render.

Source

pub fn hdr_texture(&self) -> impl Deref<Target = Texture> + '_

Source

pub fn commit(&self) -> StageCommitResult

Run all upkeep and commit all staged changes to the GPU.

This is done implicitly in Stage::render.

This can be used after dropping resources to reclaim those resources on the GPU.

Source

pub fn create_primitive_pipeline( device: &Device, fragment_color_format: TextureFormat, multisample_count: u32, ) -> RenderPipeline

Source

pub fn new(ctx: &Context) -> Self

Create a new stage.

Source

pub fn set_background_color(&self, color: impl Into<Vec4>)

Source

pub fn with_background_color(self, color: impl Into<Vec4>) -> Self

Source

pub fn get_msaa_sample_count(&self) -> u32

Return the multisample count.

Source

pub fn set_msaa_sample_count(&self, multisample_count: u32)

Set the MSAA multisample count.

Set to 1 to disable MSAA. Setting to 0 will be treated the same as setting to 1.

Source

pub fn with_msaa_sample_count(self, multisample_count: u32) -> Self

Set the MSAA multisample count.

Set to 1 to disable MSAA. Setting to 0 will be treated the same as setting to 1.

Source

pub fn set_clear_color_attachments(&self, should_clear: bool)

Set whether color attachments are cleared before rendering.

Source

pub fn with_clear_color_attachments(self, should_clear: bool) -> Self

Set whether color attachments are cleared before rendering.

Source

pub fn set_clear_depth_attachments(&self, should_clear: bool)

Set whether color attachments are cleared before rendering.

Source

pub fn with_clear_depth_attachments(self, should_clear: bool) -> Self

Set whether color attachments are cleared before rendering.

Source

pub fn set_debug_mode(&self, debug_mode: DebugChannel)

Set the debug mode.

Source

pub fn with_debug_mode(self, debug_mode: DebugChannel) -> Self

Set the debug mode.

Source

pub fn set_use_debug_overlay(&self, use_debug_overlay: bool)

Set whether to render the debug overlay.

Source

pub fn with_debug_overlay(self, use_debug_overlay: bool) -> Self

Set whether to render the debug overlay.

Source

pub fn set_use_frustum_culling(&self, use_frustum_culling: bool)

Set whether to use frustum culling on GPU before drawing.

This defaults to true.

Source

pub fn with_frustum_culling(self, use_frustum_culling: bool) -> Self

Set whether to render the debug overlay.

Source

pub fn set_use_occlusion_culling(&self, use_occlusion_culling: bool)

Set whether to use occlusion culling on GPU before drawing.

This defaults to false.

§Warning

Occlusion culling is a feature in development. YMMV.

Source

pub fn with_occlusion_culling(self, use_occlusion_culling: bool) -> Self

Set whether to render the debug overlay.

Source

pub fn set_has_lighting(&self, use_lighting: bool)

Set whether the stage uses lighting.

Source

pub fn with_lighting(self, use_lighting: bool) -> Self

Set whether the stage uses lighting.

Source

pub fn set_has_vertex_skinning(&self, use_skinning: bool)

Set whether to use vertex skinning.

Source

pub fn with_vertex_skinning(self, use_skinning: bool) -> Self

Set whether to use vertex skinning.

Source

pub fn get_size(&self) -> UVec2

Source

pub fn set_size(&self, size: UVec2)

Source

pub fn with_size(self, size: UVec2) -> Self

Source

pub fn set_has_bloom(&self, has_bloom: bool)

Turn the bloom effect on or off.

Source

pub fn with_bloom(self, has_bloom: bool) -> Self

Turn the bloom effect on or off.

Source

pub fn set_bloom_mix_strength(&self, strength: f32)

Set the amount of bloom that is mixed in with the input image.

Defaults to 0.04.

Source

pub fn with_bloom_mix_strength(self, strength: f32) -> Self

Source

pub fn set_bloom_filter_radius(&self, filter_radius: f32)

Sets the bloom filter radius, in pixels.

Default is 1.0.

Source

pub fn with_bloom_filter_radius(self, filter_radius: f32) -> Self

Sets the bloom filter radius, in pixels.

Default is 1.0.

Source

pub fn add_primitive(&self, primitive: &Primitive) -> usize

Adds a primitive to the internal list of primitives to be drawn each frame.

Returns the number of primitives added.

If you drop the primitive and no other references are kept, it will be removed automatically from the internal list and will cease to be drawn each frame.

Source

pub fn remove_primitive(&self, primitive: &Primitive) -> usize

Erase the given primitive from the internal list of primitives to be drawn each frame.

Returns the number of primitives added.

Source

pub fn sort_primitive(&self, f: impl Fn(&Primitive, &Primitive) -> Ordering)

Sort the drawing order of primitives.

This determines the order in which Primitives are drawn each frame.

Source

pub fn get_depth_texture(&self) -> DepthTexture

Returns a clone of the current depth texture.

Source

pub fn new_nested_transform(&self) -> NestedTransform

Create a new NestedTransform.

Source

pub fn render(&self, view: &TextureView)

Render the staged scene into the given view.

Trait Implementations§

Source§

impl AsRef<Geometry> for Stage

Source§

fn as_ref(&self) -> &Geometry

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Lighting> for Stage

Source§

fn as_ref(&self) -> &Lighting

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<Materials> for Stage

Source§

fn as_ref(&self) -> &Materials

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl AsRef<WgpuRuntime> for Stage

Source§

fn as_ref(&self) -> &WgpuRuntime

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for Stage

Source§

fn clone(&self) -> Stage

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl Freeze for Stage

§

impl !RefUnwindSafe for Stage

§

impl Send for Stage

§

impl Sync for Stage

§

impl Unpin for Stage

§

impl !UnwindSafe for Stage

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
Source§

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

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,