pub struct FunctionCall { /* private fields */ }Expand description
Validated client function call requested by a model.
§Examples
use providers_kit::generation::FunctionCall;
let call = FunctionCall::new(Some("call-1".into()), "lookup", serde_json::json!({"key":"a"}))?;
assert_eq!(call.id(), Some("call-1"));
assert_eq!(call.name(), "lookup");
assert_eq!(call.arguments()["key"], "a");
Implementations§
Source§impl FunctionCall
impl FunctionCall
Sourcepub fn new(
id: Option<String>,
name: impl Into<String>,
arguments: Value,
) -> Result<Self, KitError>
pub fn new( id: Option<String>, name: impl Into<String>, arguments: Value, ) -> Result<Self, KitError>
Creates a validated function call.
§Errors
Returns an input error for an invalid portable function name, invalid optional call id, or arguments that are not a JSON object. Keep returned call correlation unchanged in its result.
§Examples
use providers_kit::generation::FunctionCall;
let call = FunctionCall::new(Some("call-1".into()), "lookup", serde_json::json!({"key":"a"}))?;
assert_eq!(call.id(), Some("call-1"));
assert_eq!(call.name(), "lookup");
assert_eq!(call.arguments()["key"], "a");
Sourcepub fn id(&self) -> Option<&str>
pub fn id(&self) -> Option<&str>
Returns the provider correlation id, when one was supplied.
§Examples
use providers_kit::generation::FunctionCall;
let call = FunctionCall::new(Some("call-1".into()), "lookup", serde_json::json!({"key":"a"}))?;
assert_eq!(call.id(), Some("call-1"));
assert_eq!(call.name(), "lookup");
assert_eq!(call.arguments()["key"], "a");
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the function name.
§Examples
use providers_kit::generation::FunctionCall;
let call = FunctionCall::new(Some("call-1".into()), "lookup", serde_json::json!({"key":"a"}))?;
assert_eq!(call.id(), Some("call-1"));
assert_eq!(call.name(), "lookup");
assert_eq!(call.arguments()["key"], "a");
Sourcepub fn arguments(&self) -> &Value
pub fn arguments(&self) -> &Value
Returns the validated object-shaped arguments.
§Examples
use providers_kit::generation::FunctionCall;
let call = FunctionCall::new(Some("call-1".into()), "lookup", serde_json::json!({"key":"a"}))?;
assert_eq!(call.id(), Some("call-1"));
assert_eq!(call.name(), "lookup");
assert_eq!(call.arguments()["key"], "a");
Trait Implementations§
Source§impl Clone for FunctionCall
impl Clone for FunctionCall
Source§impl Debug for FunctionCall
impl Debug for FunctionCall
Source§impl<'de> Deserialize<'de> for FunctionCall
impl<'de> Deserialize<'de> for FunctionCall
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for FunctionCall
impl PartialEq for FunctionCall
Source§impl Serialize for FunctionCall
impl Serialize for FunctionCall
impl StructuralPartialEq for FunctionCall
Auto Trait Implementations§
impl Freeze for FunctionCall
impl RefUnwindSafe for FunctionCall
impl Send for FunctionCall
impl Sync for FunctionCall
impl Unpin for FunctionCall
impl UnsafeUnpin for FunctionCall
impl UnwindSafe for FunctionCall
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