Skip to main content

bevy_material/
descriptor.rs

1use alloc::borrow::Cow;
2use bevy_asset::Handle;
3use bevy_derive::Deref;
4use bevy_mesh::VertexBufferLayout;
5use bevy_shader::{CachedPipelineId, Shader, ShaderDefVal};
6use core::iter;
7use thiserror::Error;
8use wgpu_types::{
9    BindGroupLayoutEntry, ColorTargetState, DepthStencilState, MultisampleState, PrimitiveState,
10};
11
12#[derive(#[automatically_derived]
impl ::core::clone::Clone for BindGroupLayoutDescriptor {
    #[inline]
    fn clone(&self) -> BindGroupLayoutDescriptor {
        BindGroupLayoutDescriptor {
            label: ::core::clone::Clone::clone(&self.label),
            entries: ::core::clone::Clone::clone(&self.entries),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for BindGroupLayoutDescriptor {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field2_finish(f,
            "BindGroupLayoutDescriptor", "label", &self.label, "entries",
            &&self.entries)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for BindGroupLayoutDescriptor {
    #[inline]
    fn eq(&self, other: &BindGroupLayoutDescriptor) -> bool {
        self.label == other.label && self.entries == other.entries
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for BindGroupLayoutDescriptor {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Cow<'static, str>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<BindGroupLayoutEntry>>;
    }
}Eq, #[automatically_derived]
impl ::core::hash::Hash for BindGroupLayoutDescriptor {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.label, state);
        ::core::hash::Hash::hash(&self.entries, state)
    }
}Hash, #[automatically_derived]
impl ::core::default::Default for BindGroupLayoutDescriptor {
    #[inline]
    fn default() -> BindGroupLayoutDescriptor {
        BindGroupLayoutDescriptor {
            label: ::core::default::Default::default(),
            entries: ::core::default::Default::default(),
        }
    }
}Default)]
13pub struct BindGroupLayoutDescriptor {
14    /// Debug label of the bind group layout descriptor. This will show up in graphics debuggers for easy identification.
15    pub label: Cow<'static, str>,
16    pub entries: Vec<BindGroupLayoutEntry>,
17}
18
19impl BindGroupLayoutDescriptor {
20    pub fn new(label: impl Into<Cow<'static, str>>, entries: &[BindGroupLayoutEntry]) -> Self {
21        Self {
22            label: label.into(),
23            entries: entries.into(),
24        }
25    }
26}
27
28/// Describes a render (graphics) pipeline.
29#[derive(#[automatically_derived]
impl ::core::clone::Clone for RenderPipelineDescriptor {
    #[inline]
    fn clone(&self) -> RenderPipelineDescriptor {
        RenderPipelineDescriptor {
            label: ::core::clone::Clone::clone(&self.label),
            layout: ::core::clone::Clone::clone(&self.layout),
            immediate_size: ::core::clone::Clone::clone(&self.immediate_size),
            vertex: ::core::clone::Clone::clone(&self.vertex),
            primitive: ::core::clone::Clone::clone(&self.primitive),
            depth_stencil: ::core::clone::Clone::clone(&self.depth_stencil),
            multisample: ::core::clone::Clone::clone(&self.multisample),
            fragment: ::core::clone::Clone::clone(&self.fragment),
            zero_initialize_workgroup_memory: ::core::clone::Clone::clone(&self.zero_initialize_workgroup_memory),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for RenderPipelineDescriptor {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["label", "layout", "immediate_size", "vertex", "primitive",
                        "depth_stencil", "multisample", "fragment",
                        "zero_initialize_workgroup_memory"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.label, &self.layout, &self.immediate_size, &self.vertex,
                        &self.primitive, &self.depth_stencil, &self.multisample,
                        &self.fragment, &&self.zero_initialize_workgroup_memory];
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "RenderPipelineDescriptor", names, values)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for RenderPipelineDescriptor {
    #[inline]
    fn eq(&self, other: &RenderPipelineDescriptor) -> bool {
        self.immediate_size == other.immediate_size &&
                                        self.zero_initialize_workgroup_memory ==
                                            other.zero_initialize_workgroup_memory &&
                                    self.label == other.label && self.layout == other.layout &&
                            self.vertex == other.vertex &&
                        self.primitive == other.primitive &&
                    self.depth_stencil == other.depth_stencil &&
                self.multisample == other.multisample &&
            self.fragment == other.fragment
    }
}PartialEq, #[automatically_derived]
impl ::core::default::Default for RenderPipelineDescriptor {
    #[inline]
    fn default() -> RenderPipelineDescriptor {
        RenderPipelineDescriptor {
            label: ::core::default::Default::default(),
            layout: ::core::default::Default::default(),
            immediate_size: ::core::default::Default::default(),
            vertex: ::core::default::Default::default(),
            primitive: ::core::default::Default::default(),
            depth_stencil: ::core::default::Default::default(),
            multisample: ::core::default::Default::default(),
            fragment: ::core::default::Default::default(),
            zero_initialize_workgroup_memory: ::core::default::Default::default(),
        }
    }
}Default)]
30pub struct RenderPipelineDescriptor {
31    /// Debug label of the pipeline. This will show up in graphics debuggers for easy identification.
32    pub label: Option<Cow<'static, str>>,
33    /// The layout of bind groups for this pipeline.
34    pub layout: Vec<BindGroupLayoutDescriptor>,
35    /// The immediate size for this pipeline.
36    /// Supply 0 if the pipeline doesn't use push constants/immediates.
37    pub immediate_size: u32,
38    /// The compiled vertex stage, its entry point, and the input buffers layout.
39    pub vertex: VertexState,
40    /// The properties of the pipeline at the primitive assembly and rasterization level.
41    pub primitive: PrimitiveState,
42    /// The effect of draw calls on the depth and stencil aspects of the output target, if any.
43    pub depth_stencil: Option<DepthStencilState>,
44    /// The multi-sampling properties of the pipeline.
45    pub multisample: MultisampleState,
46    /// The compiled fragment stage, its entry point, and the color targets.
47    pub fragment: Option<FragmentState>,
48    /// Whether to zero-initialize workgroup memory by default. If you're not sure, set this to true.
49    /// If this is false, reading from workgroup variables before writing to them will result in garbage values.
50    pub zero_initialize_workgroup_memory: bool,
51}
52
53#[derive(#[automatically_derived]
impl ::core::marker::Copy for NoFragmentStateError { }Copy, #[automatically_derived]
impl ::core::clone::Clone for NoFragmentStateError {
    #[inline]
    fn clone(&self) -> NoFragmentStateError { *self }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for NoFragmentStateError {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::write_str(f, "NoFragmentStateError")
    }
}Debug, #[allow(unused_qualifications)]
#[automatically_derived]
impl ::core::fmt::Display for NoFragmentStateError {
    #[allow(clippy :: used_underscore_binding)]
    fn fmt(&self, __formatter: &mut ::core::fmt::Formatter)
        -> ::core::fmt::Result {
        #[allow(unused_variables, deprecated)]
        let Self {} = self;
        __formatter.write_str("RenderPipelineDescriptor has no FragmentState configured")
    }
}Error)]
54#[error("RenderPipelineDescriptor has no FragmentState configured")]
55pub struct NoFragmentStateError;
56
57impl RenderPipelineDescriptor {
58    pub fn fragment_mut(&mut self) -> Result<&mut FragmentState, NoFragmentStateError> {
59        self.fragment.as_mut().ok_or(NoFragmentStateError)
60    }
61
62    pub fn set_layout(&mut self, index: usize, layout: BindGroupLayoutDescriptor) {
63        filling_set_at(&mut self.layout, index, bevy_utils::default(), layout);
64    }
65}
66
67#[derive(#[automatically_derived]
impl ::core::clone::Clone for VertexState {
    #[inline]
    fn clone(&self) -> VertexState {
        VertexState {
            shader: ::core::clone::Clone::clone(&self.shader),
            shader_defs: ::core::clone::Clone::clone(&self.shader_defs),
            entry_point: ::core::clone::Clone::clone(&self.entry_point),
            buffers: ::core::clone::Clone::clone(&self.buffers),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for VertexState {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "VertexState",
            "shader", &self.shader, "shader_defs", &self.shader_defs,
            "entry_point", &self.entry_point, "buffers", &&self.buffers)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::Eq for VertexState {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Handle<Shader>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<ShaderDefVal>>;
        let _: ::core::cmp::AssertParamIsEq<Option<Cow<'static, str>>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<VertexBufferLayout>>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for VertexState {
    #[inline]
    fn eq(&self, other: &VertexState) -> bool {
        self.shader == other.shader && self.shader_defs == other.shader_defs
                && self.entry_point == other.entry_point &&
            self.buffers == other.buffers
    }
}PartialEq, #[automatically_derived]
impl ::core::default::Default for VertexState {
    #[inline]
    fn default() -> VertexState {
        VertexState {
            shader: ::core::default::Default::default(),
            shader_defs: ::core::default::Default::default(),
            entry_point: ::core::default::Default::default(),
            buffers: ::core::default::Default::default(),
        }
    }
}Default)]
68pub struct VertexState {
69    /// The compiled shader module for this stage.
70    pub shader: Handle<Shader>,
71    pub shader_defs: Vec<ShaderDefVal>,
72    /// The name of the entry point in the compiled shader, or `None` if the default entry point
73    /// is used.
74    pub entry_point: Option<Cow<'static, str>>,
75    /// The format of any vertex buffers used with this pipeline.
76    pub buffers: Vec<VertexBufferLayout>,
77}
78
79/// Describes the fragment process in a render pipeline.
80#[derive(#[automatically_derived]
impl ::core::clone::Clone for FragmentState {
    #[inline]
    fn clone(&self) -> FragmentState {
        FragmentState {
            shader: ::core::clone::Clone::clone(&self.shader),
            shader_defs: ::core::clone::Clone::clone(&self.shader_defs),
            entry_point: ::core::clone::Clone::clone(&self.entry_point),
            targets: ::core::clone::Clone::clone(&self.targets),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for FragmentState {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_struct_field4_finish(f, "FragmentState",
            "shader", &self.shader, "shader_defs", &self.shader_defs,
            "entry_point", &self.entry_point, "targets", &&self.targets)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for FragmentState {
    #[inline]
    fn eq(&self, other: &FragmentState) -> bool {
        self.shader == other.shader && self.shader_defs == other.shader_defs
                && self.entry_point == other.entry_point &&
            self.targets == other.targets
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for FragmentState {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Handle<Shader>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<ShaderDefVal>>;
        let _: ::core::cmp::AssertParamIsEq<Option<Cow<'static, str>>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<Option<ColorTargetState>>>;
    }
}Eq, #[automatically_derived]
impl ::core::default::Default for FragmentState {
    #[inline]
    fn default() -> FragmentState {
        FragmentState {
            shader: ::core::default::Default::default(),
            shader_defs: ::core::default::Default::default(),
            entry_point: ::core::default::Default::default(),
            targets: ::core::default::Default::default(),
        }
    }
}Default)]
81pub struct FragmentState {
82    /// The compiled shader module for this stage.
83    pub shader: Handle<Shader>,
84    pub shader_defs: Vec<ShaderDefVal>,
85    /// The name of the entry point in the compiled shader, or `None` if the default entry point
86    /// is used.
87    pub entry_point: Option<Cow<'static, str>>,
88    /// The color state of the render targets.
89    pub targets: Vec<Option<ColorTargetState>>,
90}
91
92impl FragmentState {
93    pub fn set_target(&mut self, index: usize, target: ColorTargetState) {
94        filling_set_at(&mut self.targets, index, None, Some(target));
95    }
96}
97
98/// Describes a compute pipeline.
99#[derive(#[automatically_derived]
impl ::core::clone::Clone for ComputePipelineDescriptor {
    #[inline]
    fn clone(&self) -> ComputePipelineDescriptor {
        ComputePipelineDescriptor {
            label: ::core::clone::Clone::clone(&self.label),
            layout: ::core::clone::Clone::clone(&self.layout),
            immediate_size: ::core::clone::Clone::clone(&self.immediate_size),
            shader: ::core::clone::Clone::clone(&self.shader),
            shader_defs: ::core::clone::Clone::clone(&self.shader_defs),
            entry_point: ::core::clone::Clone::clone(&self.entry_point),
            zero_initialize_workgroup_memory: ::core::clone::Clone::clone(&self.zero_initialize_workgroup_memory),
        }
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for ComputePipelineDescriptor {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        let names: &'static _ =
            &["label", "layout", "immediate_size", "shader", "shader_defs",
                        "entry_point", "zero_initialize_workgroup_memory"];
        let values: &[&dyn ::core::fmt::Debug] =
            &[&self.label, &self.layout, &self.immediate_size, &self.shader,
                        &self.shader_defs, &self.entry_point,
                        &&self.zero_initialize_workgroup_memory];
        ::core::fmt::Formatter::debug_struct_fields_finish(f,
            "ComputePipelineDescriptor", names, values)
    }
}Debug, #[automatically_derived]
impl ::core::cmp::PartialEq for ComputePipelineDescriptor {
    #[inline]
    fn eq(&self, other: &ComputePipelineDescriptor) -> bool {
        self.immediate_size == other.immediate_size &&
                                self.zero_initialize_workgroup_memory ==
                                    other.zero_initialize_workgroup_memory &&
                            self.label == other.label && self.layout == other.layout &&
                    self.shader == other.shader &&
                self.shader_defs == other.shader_defs &&
            self.entry_point == other.entry_point
    }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for ComputePipelineDescriptor {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<Option<Cow<'static, str>>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<BindGroupLayoutDescriptor>>;
        let _: ::core::cmp::AssertParamIsEq<u32>;
        let _: ::core::cmp::AssertParamIsEq<Handle<Shader>>;
        let _: ::core::cmp::AssertParamIsEq<Vec<ShaderDefVal>>;
        let _: ::core::cmp::AssertParamIsEq<Option<Cow<'static, str>>>;
        let _: ::core::cmp::AssertParamIsEq<bool>;
    }
}Eq, #[automatically_derived]
impl ::core::default::Default for ComputePipelineDescriptor {
    #[inline]
    fn default() -> ComputePipelineDescriptor {
        ComputePipelineDescriptor {
            label: ::core::default::Default::default(),
            layout: ::core::default::Default::default(),
            immediate_size: ::core::default::Default::default(),
            shader: ::core::default::Default::default(),
            shader_defs: ::core::default::Default::default(),
            entry_point: ::core::default::Default::default(),
            zero_initialize_workgroup_memory: ::core::default::Default::default(),
        }
    }
}Default)]
100pub struct ComputePipelineDescriptor {
101    pub label: Option<Cow<'static, str>>,
102    pub layout: Vec<BindGroupLayoutDescriptor>,
103    pub immediate_size: u32,
104    /// The compiled shader module for this stage.
105    pub shader: Handle<Shader>,
106    pub shader_defs: Vec<ShaderDefVal>,
107    /// The name of the entry point in the compiled shader, or `None` if the default entry point
108    /// is used.
109    pub entry_point: Option<Cow<'static, str>>,
110    /// Whether to zero-initialize workgroup memory by default. If you're not sure, set this to true.
111    /// If this is false, reading from workgroup variables before writing to them will result in garbage values.
112    pub zero_initialize_workgroup_memory: bool,
113}
114
115// utility function to set a value at the specified index, extending with
116// a filler value if the index is out of bounds.
117fn filling_set_at<T: Clone>(vec: &mut Vec<T>, index: usize, filler: T, value: T) {
118    let num_to_fill = (index + 1).saturating_sub(vec.len());
119    vec.extend(iter::repeat_n(filler, num_to_fill));
120    vec[index] = value;
121}
122
123/// A descriptor for a [`Pipeline`](https://docs.rs/bevy/latest/bevy/render/render_resource/enum.Pipeline.html).
124///
125/// Used to store a heterogenous collection of render and compute pipeline descriptors together.
126#[derive(#[automatically_derived]
impl ::core::fmt::Debug for PipelineDescriptor {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        match self {
            PipelineDescriptor::RenderPipelineDescriptor(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "RenderPipelineDescriptor", &__self_0),
            PipelineDescriptor::ComputePipelineDescriptor(__self_0) =>
                ::core::fmt::Formatter::debug_tuple_field1_finish(f,
                    "ComputePipelineDescriptor", &__self_0),
        }
    }
}Debug)]
127pub enum PipelineDescriptor {
128    RenderPipelineDescriptor(Box<RenderPipelineDescriptor>),
129    ComputePipelineDescriptor(Box<ComputePipelineDescriptor>),
130}
131
132/// Index of a cached render pipeline in a `PipelineCache`.
133#[derive(#[automatically_derived]
impl ::core::marker::Copy for CachedRenderPipelineId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CachedRenderPipelineId {
    #[inline]
    fn clone(&self) -> CachedRenderPipelineId {
        let _: ::core::clone::AssertParamIsClone<CachedPipelineId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CachedRenderPipelineId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f,
            "CachedRenderPipelineId", &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for CachedRenderPipelineId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}Hash, #[automatically_derived]
impl ::core::cmp::Eq for CachedRenderPipelineId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<CachedPipelineId>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for CachedRenderPipelineId {
    #[inline]
    fn eq(&self, other: &CachedRenderPipelineId) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::PartialOrd for CachedRenderPipelineId {
    #[inline]
    fn partial_cmp(&self, other: &CachedRenderPipelineId)
        -> ::core::option::Option<::core::cmp::Ordering> {
        ::core::option::Option::Some(::core::cmp::Ord::cmp(self, other))
    }
}PartialOrd, #[automatically_derived]
impl ::core::cmp::Ord for CachedRenderPipelineId {
    #[inline]
    fn cmp(&self, other: &CachedRenderPipelineId) -> ::core::cmp::Ordering {
        ::core::cmp::Ord::cmp(&self.0, &other.0)
    }
}Ord, impl ::core::ops::Deref for CachedRenderPipelineId {
    type Target = CachedPipelineId;
    fn deref(&self) -> &Self::Target { &self.0 }
}Deref)]
134pub struct CachedRenderPipelineId(CachedPipelineId);
135
136impl CachedRenderPipelineId {
137    /// An invalid cached render pipeline index, often used to initialize a variable.
138    pub const INVALID: Self = CachedRenderPipelineId(usize::MAX);
139
140    #[inline]
141    pub fn new(id: usize) -> Self {
142        Self(id)
143    }
144
145    #[inline]
146    pub fn id(&self) -> usize {
147        self.0
148    }
149}
150
151/// Index of a cached compute pipeline in a `PipelineCache`.
152#[derive(#[automatically_derived]
impl ::core::marker::Copy for CachedComputePipelineId { }Copy, #[automatically_derived]
impl ::core::clone::Clone for CachedComputePipelineId {
    #[inline]
    fn clone(&self) -> CachedComputePipelineId {
        let _: ::core::clone::AssertParamIsClone<CachedPipelineId>;
        *self
    }
}Clone, #[automatically_derived]
impl ::core::fmt::Debug for CachedComputePipelineId {
    #[inline]
    fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
        ::core::fmt::Formatter::debug_tuple_field1_finish(f,
            "CachedComputePipelineId", &&self.0)
    }
}Debug, #[automatically_derived]
impl ::core::hash::Hash for CachedComputePipelineId {
    #[inline]
    fn hash<__H: ::core::hash::Hasher>(&self, state: &mut __H) {
        ::core::hash::Hash::hash(&self.0, state)
    }
}Hash, #[automatically_derived]
impl ::core::cmp::Eq for CachedComputePipelineId {
    #[inline]
    #[doc(hidden)]
    #[coverage(off)]
    fn assert_fields_are_eq(&self) {
        let _: ::core::cmp::AssertParamIsEq<CachedPipelineId>;
    }
}Eq, #[automatically_derived]
impl ::core::cmp::PartialEq for CachedComputePipelineId {
    #[inline]
    fn eq(&self, other: &CachedComputePipelineId) -> bool {
        self.0 == other.0
    }
}PartialEq)]
153pub struct CachedComputePipelineId(CachedPipelineId);
154
155impl CachedComputePipelineId {
156    /// An invalid cached compute pipeline index, often used to initialize a variable.
157    pub const INVALID: Self = CachedComputePipelineId(usize::MAX);
158
159    #[inline]
160    pub fn new(id: usize) -> Self {
161        Self(id)
162    }
163
164    #[inline]
165    pub fn id(&self) -> usize {
166        self.0
167    }
168}