Struct PipelineCache

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

Cache for render and compute pipelines.

The cache stores existing render and compute pipelines allocated on the GPU, as well as pending creation. Pipelines inserted into the cache are identified by a unique ID, which can be used to retrieve the actual GPU object once it’s ready. The creation of the GPU pipeline object is deferred to the RenderSet::Render step, just before the render graph starts being processed, as this requires access to the GPU.

Note that the cache does not perform automatic deduplication of identical pipelines. It is up to the user not to insert the same pipeline twice to avoid wasting GPU resources.

Implementations§

Source§

impl PipelineCache

Source

pub fn pipelines(&self) -> impl Iterator<Item = &CachedPipeline>

Returns an iterator over the pipelines in the pipeline cache.

Source

pub fn waiting_pipelines(&self) -> impl Iterator<Item = usize>

Returns a iterator of the IDs of all currently waiting pipelines.

Examples found in repository?
examples/games/loading_screen.rs (line 301)
299    fn update_pipelines_ready(mut main_world: ResMut<MainWorld>, pipelines: Res<PipelineCache>) {
300        if let Some(mut pipelines_ready) = main_world.get_resource_mut::<PipelinesReady>() {
301            pipelines_ready.0 = pipelines.waiting_pipelines().count() == 0;
302        }
303    }
Source

pub fn new( device: RenderDevice, render_adapter: RenderAdapter, synchronous_pipeline_compilation: bool, ) -> PipelineCache

Create a new pipeline cache associated with the given render device.

Source

pub fn get_render_pipeline_state( &self, id: CachedRenderPipelineId, ) -> &CachedPipelineState

Get the state of a cached render pipeline.

See PipelineCache::queue_render_pipeline().

Source

pub fn get_compute_pipeline_state( &self, id: CachedComputePipelineId, ) -> &CachedPipelineState

Get the state of a cached compute pipeline.

See PipelineCache::queue_compute_pipeline().

Examples found in repository?
examples/shader/compute_shader_game_of_life.rs (line 228)
221    fn update(&mut self, world: &mut World) {
222        let pipeline = world.resource::<GameOfLifePipeline>();
223        let pipeline_cache = world.resource::<PipelineCache>();
224
225        // if the corresponding pipeline has loaded, transition to the next stage
226        match self.state {
227            GameOfLifeState::Loading => {
228                match pipeline_cache.get_compute_pipeline_state(pipeline.init_pipeline) {
229                    CachedPipelineState::Ok(_) => {
230                        self.state = GameOfLifeState::Init;
231                    }
232                    CachedPipelineState::Err(err) => {
233                        panic!("Initializing assets/{SHADER_ASSET_PATH}:\n{err}")
234                    }
235                    _ => {}
236                }
237            }
238            GameOfLifeState::Init => {
239                if let CachedPipelineState::Ok(_) =
240                    pipeline_cache.get_compute_pipeline_state(pipeline.update_pipeline)
241                {
242                    self.state = GameOfLifeState::Update(1);
243                }
244            }
245            GameOfLifeState::Update(0) => {
246                self.state = GameOfLifeState::Update(1);
247            }
248            GameOfLifeState::Update(1) => {
249                self.state = GameOfLifeState::Update(0);
250            }
251            GameOfLifeState::Update(_) => unreachable!(),
252        }
253    }
Source

pub fn get_render_pipeline_descriptor( &self, id: CachedRenderPipelineId, ) -> &RenderPipelineDescriptor

Get the render pipeline descriptor a cached render pipeline was inserted from.

See PipelineCache::queue_render_pipeline().

Note: Be careful calling this method. It will panic if called with a pipeline that has been queued but has not yet been processed by PipelineCache::process_queue().

Source

pub fn get_compute_pipeline_descriptor( &self, id: CachedComputePipelineId, ) -> &ComputePipelineDescriptor

Get the compute pipeline descriptor a cached render pipeline was inserted from.

See PipelineCache::queue_compute_pipeline().

Note: Be careful calling this method. It will panic if called with a pipeline that has been queued but has not yet been processed by PipelineCache::process_queue().

Source

pub fn get_render_pipeline( &self, id: CachedRenderPipelineId, ) -> Option<&RenderPipeline>

Try to retrieve a render pipeline GPU object from a cached ID.

§Returns

This method returns a successfully created render pipeline if any, or None if the pipeline was not created yet or if there was an error during creation. You can check the actual creation state with PipelineCache::get_render_pipeline_state().

Examples found in repository?
examples/shader/custom_post_processing.rs (line 159)
142    fn run(
143        &self,
144        _graph: &mut RenderGraphContext,
145        render_context: &mut RenderContext,
146        (view_target, _post_process_settings, settings_index): QueryItem<Self::ViewQuery>,
147        world: &World,
148    ) -> Result<(), NodeRunError> {
149        // Get the pipeline resource that contains the global data we need
150        // to create the render pipeline
151        let post_process_pipeline = world.resource::<PostProcessPipeline>();
152
153        // The pipeline cache is a cache of all previously created pipelines.
154        // It is required to avoid creating a new pipeline each frame,
155        // which is expensive due to shader compilation.
156        let pipeline_cache = world.resource::<PipelineCache>();
157
158        // Get the pipeline from the cache
159        let Some(pipeline) = pipeline_cache.get_render_pipeline(post_process_pipeline.pipeline_id)
160        else {
161            return Ok(());
162        };
163
164        // Get the settings uniform binding
165        let settings_uniforms = world.resource::<ComponentUniforms<PostProcessSettings>>();
166        let Some(settings_binding) = settings_uniforms.uniforms().binding() else {
167            return Ok(());
168        };
169
170        // This will start a new "post process write", obtaining two texture
171        // views from the view target - a `source` and a `destination`.
172        // `source` is the "current" main texture and you _must_ write into
173        // `destination` because calling `post_process_write()` on the
174        // [`ViewTarget`] will internally flip the [`ViewTarget`]'s main
175        // texture to the `destination` texture. Failing to do so will cause
176        // the current main texture information to be lost.
177        let post_process = view_target.post_process_write();
178
179        // The bind_group gets created each frame.
180        //
181        // Normally, you would create a bind_group in the Queue set,
182        // but this doesn't work with the post_process_write().
183        // The reason it doesn't work is because each post_process_write will alternate the source/destination.
184        // The only way to have the correct source/destination for the bind_group
185        // is to make sure you get it during the node execution.
186        let bind_group = render_context.render_device().create_bind_group(
187            "post_process_bind_group",
188            &post_process_pipeline.layout,
189            // It's important for this to match the BindGroupLayout defined in the PostProcessPipeline
190            &BindGroupEntries::sequential((
191                // Make sure to use the source view
192                post_process.source,
193                // Use the sampler created for the pipeline
194                &post_process_pipeline.sampler,
195                // Set the settings binding
196                settings_binding.clone(),
197            )),
198        );
199
200        // Begin the render pass
201        let mut render_pass = render_context.begin_tracked_render_pass(RenderPassDescriptor {
202            label: Some("post_process_pass"),
203            color_attachments: &[Some(RenderPassColorAttachment {
204                // We need to specify the post process destination view here
205                // to make sure we write to the appropriate texture.
206                view: post_process.destination,
207                resolve_target: None,
208                ops: Operations::default(),
209            })],
210            depth_stencil_attachment: None,
211            timestamp_writes: None,
212            occlusion_query_set: None,
213        });
214
215        // This is mostly just wgpu boilerplate for drawing a fullscreen triangle,
216        // using the pipeline/bind_group created above
217        render_pass.set_render_pipeline(pipeline);
218        // By passing in the index of the post process settings on this view, we ensure
219        // that in the event that multiple settings were sent to the GPU (as would be the
220        // case with multiple cameras), we use the correct one.
221        render_pass.set_bind_group(0, &bind_group, &[settings_index.index()]);
222        render_pass.draw(0..3, 0..1);
223
224        Ok(())
225    }
Source

pub fn block_on_render_pipeline(&mut self, id: CachedRenderPipelineId)

Wait for a render pipeline to finish compiling.

Source

pub fn get_compute_pipeline( &self, id: CachedComputePipelineId, ) -> Option<&ComputePipeline>

Try to retrieve a compute pipeline GPU object from a cached ID.

§Returns

This method returns a successfully created compute pipeline if any, or None if the pipeline was not created yet or if there was an error during creation. You can check the actual creation state with PipelineCache::get_compute_pipeline_state().

Examples found in repository?
examples/shader/gpu_readback.rs (line 207)
197    fn run(
198        &self,
199        _graph: &mut render_graph::RenderGraphContext,
200        render_context: &mut RenderContext,
201        world: &World,
202    ) -> Result<(), render_graph::NodeRunError> {
203        let pipeline_cache = world.resource::<PipelineCache>();
204        let pipeline = world.resource::<ComputePipeline>();
205        let bind_group = world.resource::<GpuBufferBindGroup>();
206
207        if let Some(init_pipeline) = pipeline_cache.get_compute_pipeline(pipeline.pipeline) {
208            let mut pass =
209                render_context
210                    .command_encoder()
211                    .begin_compute_pass(&ComputePassDescriptor {
212                        label: Some("GPU readback compute pass"),
213                        ..default()
214                    });
215
216            pass.set_bind_group(0, &bind_group.0, &[]);
217            pass.set_pipeline(init_pipeline);
218            pass.dispatch_workgroups(BUFFER_LEN as u32, 1, 1);
219        }
220        Ok(())
221    }
More examples
Hide additional examples
examples/shader/compute_shader_game_of_life.rs (line 274)
255    fn run(
256        &self,
257        _graph: &mut render_graph::RenderGraphContext,
258        render_context: &mut RenderContext,
259        world: &World,
260    ) -> Result<(), render_graph::NodeRunError> {
261        let bind_groups = &world.resource::<GameOfLifeImageBindGroups>().0;
262        let pipeline_cache = world.resource::<PipelineCache>();
263        let pipeline = world.resource::<GameOfLifePipeline>();
264
265        let mut pass = render_context
266            .command_encoder()
267            .begin_compute_pass(&ComputePassDescriptor::default());
268
269        // select the pipeline based on the current state
270        match self.state {
271            GameOfLifeState::Loading => {}
272            GameOfLifeState::Init => {
273                let init_pipeline = pipeline_cache
274                    .get_compute_pipeline(pipeline.init_pipeline)
275                    .unwrap();
276                pass.set_bind_group(0, &bind_groups[0], &[]);
277                pass.set_pipeline(init_pipeline);
278                pass.dispatch_workgroups(SIZE.0 / WORKGROUP_SIZE, SIZE.1 / WORKGROUP_SIZE, 1);
279            }
280            GameOfLifeState::Update(index) => {
281                let update_pipeline = pipeline_cache
282                    .get_compute_pipeline(pipeline.update_pipeline)
283                    .unwrap();
284                pass.set_bind_group(0, &bind_groups[index], &[]);
285                pass.set_pipeline(update_pipeline);
286                pass.dispatch_workgroups(SIZE.0 / WORKGROUP_SIZE, SIZE.1 / WORKGROUP_SIZE, 1);
287            }
288        }
289
290        Ok(())
291    }
Source

pub fn queue_render_pipeline( &self, descriptor: RenderPipelineDescriptor, ) -> CachedRenderPipelineId

Insert a render pipeline into the cache, and queue its creation.

The pipeline is always inserted and queued for creation. There is no attempt to deduplicate it with an already cached pipeline.

§Returns

This method returns the unique render shader ID of the cached pipeline, which can be used to query the caching state with get_render_pipeline_state() and to retrieve the created GPU pipeline once it’s ready with get_render_pipeline().

Examples found in repository?
examples/shader/custom_post_processing.rs (lines 266-290)
237    fn from_world(world: &mut World) -> Self {
238        let render_device = world.resource::<RenderDevice>();
239
240        // We need to define the bind group layout used for our pipeline
241        let layout = render_device.create_bind_group_layout(
242            "post_process_bind_group_layout",
243            &BindGroupLayoutEntries::sequential(
244                // The layout entries will only be visible in the fragment stage
245                ShaderStages::FRAGMENT,
246                (
247                    // The screen texture
248                    texture_2d(TextureSampleType::Float { filterable: true }),
249                    // The sampler that will be used to sample the screen texture
250                    sampler(SamplerBindingType::Filtering),
251                    // The settings uniform that will control the effect
252                    uniform_buffer::<PostProcessSettings>(true),
253                ),
254            ),
255        );
256
257        // We can create the sampler here since it won't change at runtime and doesn't depend on the view
258        let sampler = render_device.create_sampler(&SamplerDescriptor::default());
259
260        // Get the shader handle
261        let shader = world.load_asset(SHADER_ASSET_PATH);
262
263        let pipeline_id = world
264            .resource_mut::<PipelineCache>()
265            // This will add the pipeline to the cache and queue its creation
266            .queue_render_pipeline(RenderPipelineDescriptor {
267                label: Some("post_process_pipeline".into()),
268                layout: vec![layout.clone()],
269                // This will setup a fullscreen triangle for the vertex state
270                vertex: fullscreen_shader_vertex_state(),
271                fragment: Some(FragmentState {
272                    shader,
273                    shader_defs: vec![],
274                    // Make sure this matches the entry point of your shader.
275                    // It can be anything as long as it matches here and in the shader.
276                    entry_point: "fragment".into(),
277                    targets: vec![Some(ColorTargetState {
278                        format: TextureFormat::bevy_default(),
279                        blend: None,
280                        write_mask: ColorWrites::ALL,
281                    })],
282                }),
283                // All of the following properties are not important for this effect so just use the default values.
284                // This struct doesn't have the Default trait implemented because not all fields can have a default value.
285                primitive: PrimitiveState::default(),
286                depth_stencil: None,
287                multisample: MultisampleState::default(),
288                push_constant_ranges: vec![],
289                zero_initialize_workgroup_memory: false,
290            });
291
292        Self {
293            layout,
294            sampler,
295            pipeline_id,
296        }
297    }
Source

pub fn queue_compute_pipeline( &self, descriptor: ComputePipelineDescriptor, ) -> CachedComputePipelineId

Insert a compute pipeline into the cache, and queue its creation.

The pipeline is always inserted and queued for creation. There is no attempt to deduplicate it with an already cached pipeline.

§Returns

This method returns the unique compute shader ID of the cached pipeline, which can be used to query the caching state with get_compute_pipeline_state() and to retrieve the created GPU pipeline once it’s ready with get_compute_pipeline().

Examples found in repository?
examples/shader/gpu_readback.rs (lines 176-184)
162    fn from_world(world: &mut World) -> Self {
163        let render_device = world.resource::<RenderDevice>();
164        let layout = render_device.create_bind_group_layout(
165            None,
166            &BindGroupLayoutEntries::sequential(
167                ShaderStages::COMPUTE,
168                (
169                    storage_buffer::<Vec<u32>>(false),
170                    texture_storage_2d(TextureFormat::R32Uint, StorageTextureAccess::WriteOnly),
171                ),
172            ),
173        );
174        let shader = world.load_asset(SHADER_ASSET_PATH);
175        let pipeline_cache = world.resource::<PipelineCache>();
176        let pipeline = pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
177            label: Some("GPU readback compute shader".into()),
178            layout: vec![layout.clone()],
179            push_constant_ranges: Vec::new(),
180            shader: shader.clone(),
181            shader_defs: Vec::new(),
182            entry_point: "main".into(),
183            zero_initialize_workgroup_memory: false,
184        });
185        ComputePipeline { layout, pipeline }
186    }
More examples
Hide additional examples
examples/shader/compute_shader_game_of_life.rs (lines 175-183)
161    fn from_world(world: &mut World) -> Self {
162        let render_device = world.resource::<RenderDevice>();
163        let texture_bind_group_layout = render_device.create_bind_group_layout(
164            "GameOfLifeImages",
165            &BindGroupLayoutEntries::sequential(
166                ShaderStages::COMPUTE,
167                (
168                    texture_storage_2d(TextureFormat::R32Float, StorageTextureAccess::ReadOnly),
169                    texture_storage_2d(TextureFormat::R32Float, StorageTextureAccess::WriteOnly),
170                ),
171            ),
172        );
173        let shader = world.load_asset(SHADER_ASSET_PATH);
174        let pipeline_cache = world.resource::<PipelineCache>();
175        let init_pipeline = pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
176            label: None,
177            layout: vec![texture_bind_group_layout.clone()],
178            push_constant_ranges: Vec::new(),
179            shader: shader.clone(),
180            shader_defs: vec![],
181            entry_point: Cow::from("init"),
182            zero_initialize_workgroup_memory: false,
183        });
184        let update_pipeline = pipeline_cache.queue_compute_pipeline(ComputePipelineDescriptor {
185            label: None,
186            layout: vec![texture_bind_group_layout.clone()],
187            push_constant_ranges: Vec::new(),
188            shader,
189            shader_defs: vec![],
190            entry_point: Cow::from("update"),
191            zero_initialize_workgroup_memory: false,
192        });
193
194        GameOfLifePipeline {
195            texture_bind_group_layout,
196            init_pipeline,
197            update_pipeline,
198        }
199    }
Source

pub fn process_queue(&mut self)

Process the pipeline queue and create all pending pipelines if possible.

This is generally called automatically during the RenderSet::Render step, but can be called manually to force creation at a different time.

Trait Implementations§

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, U> AsBindGroupShaderType<U> for T
where U: ShaderType, &'a T: for<'a> Into<U>,

Source§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist.
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> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

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

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
Source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
Source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .tap_borrow() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Calls .tap_ref() only in debug builds, and is erased in release builds.
Source§

fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Calls .tap_ref_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

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

Source§

fn to_sample_(self) -> U

Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. 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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

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

Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> Settings for T
where T: 'static + Send + Sync,

Source§

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

Source§

impl<T> WasmNotSendSync for T

Source§

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