StdLib

Struct StdLib 

Source
pub struct StdLib;
Expand description

Standard library function implementations

Implementations§

Source§

impl StdLib

Source

pub fn dispatch( &self, func_name: &str, args: &[JsonnetValue], ) -> Result<JsonnetValue>

Dispatches a standard library function call.

Source

pub fn ai_http_get(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

ai.httpGet(url, headers?) - HTTP GET request

Source

pub fn ai_http_post(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

ai.httpPost(url, body, headers?) - HTTP POST request

Source

pub fn ai_call_model(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

ai.callModel(model, prompt, options?) - Call AI model

Source

pub fn tool_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

tool.execute(name, args) - Execute external tool

Source

pub fn memory_get(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

memory.get(key) - Get value from memory

Source

pub fn memory_set(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

memory.set(key, value) - Set value in memory

Source

pub fn agent_create(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

agent.create(config) - Create AI agent

Source

pub fn std_ext_var(&self, args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.extVar(name) - Get external variable

Source

pub fn std_manifest_json(&self, args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.manifestJson(value, indent?) - JSON manifest with optional indentation

Source

pub fn length(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.length(x) - returns length of array, string, or object

Source

pub fn to_string(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.toString(x) - converts value to string

Source

pub fn join(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.join(sep, arr) - joins array elements with separator

Source

pub fn substr(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.substr(s, from, len) - extracts substring

Source

pub fn split(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.split(str, sep) - splits string by separator

Source

pub fn starts_with(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.startsWith(str, prefix) - checks if string starts with prefix

Source

pub fn ends_with(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.endsWith(str, suffix) - checks if string ends with suffix

Source

pub fn string_chars(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.stringChars(str) - splits string into array of characters

Source

pub fn ascii_lower(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.asciiLower(str) - converts ASCII characters to lowercase

Source

pub fn ascii_upper(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.asciiUpper(str) - converts ASCII characters to uppercase

Source

pub fn flat_map(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.flatMap(func, arr) - apply function to each element and flatten result

Source

pub fn map_with_index(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.mapWithIndex(func, arr) - map array with index

Source

pub fn lstrip_chars(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.lstripChars(str, chars) - strip characters from left

Source

pub fn rstrip_chars(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.rstripChars(str, chars) - strip characters from right

Source

pub fn strip_chars(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.stripChars(str, chars) - strip characters from both sides

Source

pub fn find_substr(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.findSubstr(pat, str) - find all positions of substring

Source

pub fn repeat(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.repeat(what, count) - repeat value or array

Source

pub fn set(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.set(arr) - remove duplicates from array

Source

pub fn set_member(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.setMember(x, arr) - check if x is in the set arr

Source

pub fn set_inter(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.setInter(a, b) - intersection of two sets

Source

pub fn set_union(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.setUnion(a, b) - union of two sets

Source

pub fn set_diff(args: Vec<JsonnetValue>) -> Result<JsonnetValue>

std.setDiff(a, b) - difference of two sets (a - b)

Source

pub fn call_function( name: &str, args: Vec<JsonnetValue>, ) -> Result<JsonnetValue>

Call a standard library function (static method)

Auto Trait Implementations§

§

impl Freeze for StdLib

§

impl RefUnwindSafe for StdLib

§

impl Send for StdLib

§

impl Sync for StdLib

§

impl Unpin for StdLib

§

impl UnwindSafe for StdLib

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> 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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.