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

Method invoke

lib/dsc-lib/src/functions/base64_to_string.rs:31–51  ·  view source on GitHub ↗
(&self, args: &[Value], _context: &Context)

Source from the content-addressed store, hash-verified

29 }
30
31 fn invoke(&self, args: &[Value], _context: &Context) -> Result<Value, DscError> {
32 debug!("{}", t!("functions.base64ToString.invoked"));
33
34 let base64_value = args[0].as_str().unwrap();
35
36 let decoded_bytes = general_purpose::STANDARD.decode(base64_value).map_err(|_| {
37 DscError::FunctionArg(
38 "base64ToString".to_string(),
39 t!("functions.base64ToString.invalidBase64").to_string(),
40 )
41 })?;
42
43 let result = String::from_utf8(decoded_bytes).map_err(|_| {
44 DscError::FunctionArg(
45 "base64ToString".to_string(),
46 t!("functions.base64ToString.invalidUtf8").to_string(),
47 )
48 })?;
49
50 Ok(Value::String(result))
51 }
52}
53
54#[cfg(test)]

Callers

nothing calls this directly

Calls 2

FunctionArgEnum · 0.85
as_strMethod · 0.80

Tested by

no test coverage detected