pub struct Client { /* private fields */ }Expand description
A blocking client for the System One API.
Cloning is cheap and shares the connection pool.
use typesafe::blocking::Client;
use typesafe::{Noul, Questions};
let client = Client::new(); // reads TYPESAFE_API_KEY
let questions = Questions::new().ask("billing", Noul::new("Is this ticket about billing?"));
let response = client.system_one("I was charged twice!", &questions)?;
println!("{:.2}", response.noul("billing").unwrap().noul);Implementations§
Source§impl Client
impl Client
Sourcepub fn new() -> Self
pub fn new() -> Self
A client configured from the environment (Config::from_env).
§Panics
If the TLS backend can’t be initialized, or if called from inside an
async runtime, as reqwest::blocking::Client::new does.
Client::with_config returns the first as an error instead.
pub fn with_config(config: Config) -> Result<Self, Error>
pub fn config(&self) -> &Config
Sourcepub fn is_configured(&self) -> bool
pub fn is_configured(&self) -> bool
Whether the client has an API key.
Sourcepub fn system_one<S: Serialize + ?Sized>(
&self,
state: &S,
questions: &Questions,
) -> Result<Response, Error>
pub fn system_one<S: Serialize + ?Sized>( &self, state: &S, questions: &Questions, ) -> Result<Response, Error>
Asks questions about state in one request.
state is a string, or anything that serializes to a JSON object or
array. A struct keeps its field order on the wire.
Sourcepub fn system_one_with<S: Serialize + ?Sized>(
&self,
state: &S,
questions: &Questions,
options: &CallOptions,
) -> Result<Response, Error>
pub fn system_one_with<S: Serialize + ?Sized>( &self, state: &S, questions: &Questions, options: &CallOptions, ) -> Result<Response, Error>
system_one with per-call overrides.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client
impl Freeze for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnsafeUnpin for Client
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