pub struct WGSLFunction {
pub name: String,
pub entry_point: WGSLEntryPoint,
pub params: Vec<WGSLParam>,
pub return_type: Option<WGSLType>,
pub return_attrib: WGSLReturnAttrib,
pub body: Vec<String>,
}Expand description
A WGSL function (helper or entry point).
Fields§
§name: StringFunction name.
entry_point: WGSLEntryPointEntry-point kind (or None for helpers).
params: Vec<WGSLParam>Ordered parameters.
return_type: Option<WGSLType>Return type (None means no return value / void).
return_attrib: WGSLReturnAttribOptional attribute on the return type.
body: Vec<String>Body statements.
Implementations§
Source§impl WGSLFunction
impl WGSLFunction
Sourcepub fn helper(name: impl Into<String>) -> Self
pub fn helper(name: impl Into<String>) -> Self
Create a helper function with no entry-point annotation.
Sourcepub fn compute(name: impl Into<String>, x: u32, y: u32, z: u32) -> Self
pub fn compute(name: impl Into<String>, x: u32, y: u32, z: u32) -> Self
Create a @compute @workgroup_size(x, y, z) entry-point function.
Sourcepub fn set_return_type(&mut self, ty: WGSLType)
pub fn set_return_type(&mut self, ty: WGSLType)
Set the return type.
Sourcepub fn set_return_type_with_attrib(
&mut self,
ty: WGSLType,
attrib: WGSLReturnAttrib,
)
pub fn set_return_type_with_attrib( &mut self, ty: WGSLType, attrib: WGSLReturnAttrib, )
Set the return type with an attribute.
Sourcepub fn add_statement(&mut self, stmt: impl Into<String>)
pub fn add_statement(&mut self, stmt: impl Into<String>)
Append a body statement (without trailing semicolon — the emitter adds it).
Trait Implementations§
Source§impl Clone for WGSLFunction
impl Clone for WGSLFunction
Source§fn clone(&self) -> WGSLFunction
fn clone(&self) -> WGSLFunction
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for WGSLFunction
impl RefUnwindSafe for WGSLFunction
impl Send for WGSLFunction
impl Sync for WGSLFunction
impl Unpin for WGSLFunction
impl UnsafeUnpin for WGSLFunction
impl UnwindSafe for WGSLFunction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more