MCPcopy Create free account
hub / github.com/PowerShell/DSC / new

Method new

lib/dsc-lib/src/parser/functions.rs:82–103  ·  view source on GitHub ↗

Create a new `Function` instance. # Arguments `function_dispatcher` - The function dispatcher to use. `statement` - The statement that the function is part of. `function` - The function node. # Errors This function will return an error if the function node is not valid.

(statement_bytes: &[u8], function: &Node)

Source from the content-addressed store, hash-verified

80 ///
81 /// This function will return an error if the function node is not valid.
82 pub fn new(statement_bytes: &[u8], function: &Node) -> Result<Self, DscError> {
83 let mut function_name = None;
84 let mut function_args = None;
85 let mut cursor = function.walk();
86 for member in function.named_children(&mut cursor) {
87 match member.kind() {
88 "arguments" => function_args = Some(member),
89 "functionName" => function_name = Some(member),
90 "ERROR" => return Err(DscError::Parser(t!("parser.functions.foundErrorNode").to_string())),
91 _ => {}
92 }
93 }
94 let Some(name) = function_name else {
95 return Err(DscError::Parser(t!("parser.functions.nameNodeNotFound").to_string()));
96 };
97 let args = convert_args_node(statement_bytes, function_args.as_ref())?;
98 let name = name.utf8_text(statement_bytes)?;
99 debug!("{}", t!("parser.functions.functionName", name = name));
100 Ok(Function{
101 name: name.to_string(),
102 args})
103 }
104
105 /// Invoke the function.
106 ///

Callers

nothing calls this directly

Calls 2

convert_args_nodeFunction · 0.85
as_refMethod · 0.45

Tested by

no test coverage detected