pub enum JsonnetValue {
Null,
Boolean(bool),
Number(f64),
String(String),
Array(Vec<JsonnetValue>),
Object(HashMap<String, JsonnetValue>),
Function(JsonnetFunction),
Builtin(JsonnetBuiltin),
}
Expand description
Jsonnet value types
Variants§
Null
Null value
Boolean(bool)
Boolean value
Number(f64)
Number value (f64)
String(String)
String value
Array(Vec<JsonnetValue>)
Array value
Object(HashMap<String, JsonnetValue>)
Object value
Function(JsonnetFunction)
Function value
Builtin(JsonnetBuiltin)
Builtin function value
Implementations§
Source§impl JsonnetValue
impl JsonnetValue
Sourcepub fn from_json_value(value: Value) -> Self
pub fn from_json_value(value: Value) -> Self
Convert from serde_json::Value to JsonnetValue
Sourcepub fn slice(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn slice(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
slice(array|string, start, [end]) - Extract slice from array or string
Sourcepub fn zip(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn zip(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
zip(arrays…) - Zip multiple arrays together
Sourcepub fn transpose(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn transpose(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
transpose(matrix) - Transpose a matrix (array of arrays)
Sourcepub fn flatten(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn flatten(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
flatten(array, [depth]) - Completely flatten nested arrays
Sourcepub fn sum(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn sum(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
sum(array) - Sum all numbers in array
Sourcepub fn product(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn product(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
product(array) - Product of all numbers in array
Sourcepub fn all(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn all(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
all(array) - Check if all elements are truthy
Sourcepub fn any(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn any(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
any(array) - Check if any element is truthy
Sourcepub fn sort_by(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn sort_by(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
sortBy(array, keyFunc) - Sort array by key function
Sourcepub fn group_by(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn group_by(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
groupBy(array, keyFunc) - Group array elements by key function
Sourcepub fn partition(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn partition(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
partition(array, predFunc) - Partition array by predicate function
Sourcepub fn chunk(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn chunk(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
chunk(array, size) - Split array into chunks of given size
Sourcepub fn unique(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn unique(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
unique(array) - Remove duplicates from array (alternative to uniq)
Sourcepub fn difference(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn difference(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
difference(arrays…) - Set difference of arrays
Sourcepub fn intersection(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn intersection(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
intersection(arrays…) - Set intersection of arrays
Sourcepub fn symmetric_difference(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn symmetric_difference(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
symmetricDifference(a, b) - Symmetric difference of two arrays
Sourcepub fn is_subset(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn is_subset(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
isSubset(a, b) - Check if a is subset of b
Sourcepub fn is_superset(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn is_superset(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
isSuperset(a, b) - Check if a is superset of b
Sourcepub fn is_disjoint(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn is_disjoint(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
isDisjoint(a, b) - Check if a and b are disjoint
Sourcepub fn cartesian(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn cartesian(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
cartesian(arrays) - Cartesian product of arrays
Sourcepub fn cross(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn cross(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
cross(a, b) - Cross product of two arrays
Sourcepub fn dot(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn dot(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
dot(a, b) - Dot product of two numeric arrays
Sourcepub fn norm(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn norm(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
norm(array) - Euclidean norm of numeric array
Sourcepub fn normalize(&mut self, args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn normalize(&mut self, args: Vec<JsonnetValue>) -> Result<JsonnetValue>
normalize(array) - Normalize numeric array
Sourcepub fn distance(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn distance(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
distance(a, b) - Euclidean distance between two points
Sourcepub fn angle(&mut self, args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn angle(&mut self, args: Vec<JsonnetValue>) -> Result<JsonnetValue>
angle(a, b) - Angle between two vectors
Sourcepub fn rotate(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn rotate(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
rotate(point, angle, [center]) - Rotate 2D point
Sourcepub fn scale(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn scale(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
scale(point, factor, [center]) - Scale 2D point
Sourcepub fn translate(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn translate(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
translate(point, offset) - Translate 2D point
Sourcepub fn reflect(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn reflect(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
reflect(point, axis) - Reflect 2D point over axis
Sourcepub fn affine(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn affine(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
affine(point, matrix) - Apply affine transformation
Sourcepub fn split_limit(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn split_limit(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
splitLimit(string, sep, limit) - Split string with limit
Sourcepub fn join_variadic(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn join_variadic(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
join(sep, arrays…) - Join arrays with separator (variadic version)
Sourcepub fn replace(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn replace(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
replace(string, old, new) - Replace all occurrences
Sourcepub fn contains_variadic(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn contains_variadic(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
contains(container, element) - Check if container contains element
Sourcepub fn ai_http_get(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn ai_http_get(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
ai.httpGet(url, headers={}) - Make HTTP GET request
Sourcepub fn ai_http_post(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn ai_http_post(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
ai.httpPost(url, body, headers={}) - Make HTTP POST request
Sourcepub fn ai_call_model(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn ai_call_model(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
ai.callModel(model, messages, options={}) - Call AI model
Sourcepub fn tool_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn tool_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
tool.execute(command, args=[], env={}) - Execute external command
Sourcepub fn memory_get(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn memory_get(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
memory.get(key) - Get value from memory
Sourcepub fn memory_set(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn memory_set(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
memory.set(key, value) - Set value in memory
Sourcepub fn agent_create(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn agent_create(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
agent.create(type, config) - Create an AI agent
Sourcepub fn agent_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn agent_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
agent.execute(agent, input) - Execute agent with input
Sourcepub fn chain_create(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn chain_create(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
chain.create(steps) - Create a processing chain
Sourcepub fn chain_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
pub fn chain_execute(args: Vec<JsonnetValue>) -> Result<JsonnetValue>
chain.execute(chain, input) - Execute a processing chain
Source§impl JsonnetValue
impl JsonnetValue
Sourcepub fn array(values: Vec<JsonnetValue>) -> Self
pub fn array(values: Vec<JsonnetValue>) -> Self
Create an array value
Sourcepub fn object(fields: HashMap<String, JsonnetValue>) -> Self
pub fn object(fields: HashMap<String, JsonnetValue>) -> Self
Create an object value
Sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Convert to serde_json::Value for serialization
Sourcepub fn as_boolean(&self) -> Result<bool>
pub fn as_boolean(&self) -> Result<bool>
Try to convert to a boolean
Sourcepub fn as_array(&self) -> Result<&Vec<JsonnetValue>>
pub fn as_array(&self) -> Result<&Vec<JsonnetValue>>
Try to convert to an array
Sourcepub fn get_field(&self, field: &str) -> Result<&JsonnetValue>
pub fn get_field(&self, field: &str) -> Result<&JsonnetValue>
Get a field from an object
Sourcepub fn get_index(&self, index: i64) -> Result<&JsonnetValue>
pub fn get_index(&self, index: i64) -> Result<&JsonnetValue>
Get an element from an array by index
Sourcepub fn equals(&self, other: &JsonnetValue) -> bool
pub fn equals(&self, other: &JsonnetValue) -> bool
Check if two values are equal
pub fn add(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn sub(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn mul(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn div(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn modulo(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn lt(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn le(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn gt(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn ge(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn eq(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn ne(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn and(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn or(&self, other: &JsonnetValue) -> Result<JsonnetValue>
pub fn not(&self) -> Result<JsonnetValue>
pub fn neg(&self) -> Result<JsonnetValue>
Trait Implementations§
Source§impl Clone for JsonnetValue
impl Clone for JsonnetValue
Source§fn clone(&self) -> JsonnetValue
fn clone(&self) -> JsonnetValue
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more