#[repr(C)]pub struct Host {
pub ctx: *mut c_void,
pub query: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>,
pub log: Option<extern "C" fn(ctx: *mut c_void, level: i32, message: *const c_char)>,
pub config: Option<extern "C" fn(ctx: *mut c_void) -> *mut c_char>,
pub principal_id: Option<extern "C" fn(ctx: *mut c_void) -> *mut c_char>,
pub hook: Option<extern "C" fn(ctx: *mut c_void) -> *mut c_char>,
pub free_string: Option<extern "C" fn(ctx: *mut c_void, string: *mut c_char)>,
pub send_email: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>,
pub cache: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>,
pub payments: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>,
pub ai: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>,
pub emit: Option<extern "C" fn(ctx: *mut c_void, chunk: *const c_char) -> i32>,
}Expand description
Services the host lends to a C function for the duration of one call.
The host fills this in and passes a pointer that is valid only until
apiplant_invoke returns; ctx must be handed back to every callback
untouched. Each char * the host returns is owned by the callee and must be
released with free_string.
Fields§
§ctx: *mut c_voidOpaque host state. Pass it back to every callback; never dereference it.
query: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>Run a query. request_json is {"sql": "…", "params": [ … ]}. Returns a
JSON array of rows, {"rows_affected": n}, or {"error": "…"} when the
query failed — the shape distinguishes them, so there is no out-param.
log: Option<extern "C" fn(ctx: *mut c_void, level: i32, message: *const c_char)>Emit a log line through the host’s tracing subscriber. level is one of
log_level; anything else is treated as INFO.
config: Option<extern "C" fn(ctx: *mut c_void) -> *mut c_char>The function’s resolved configuration, as a JSON object.
principal_id: Option<extern "C" fn(ctx: *mut c_void) -> *mut c_char>Id of the authenticated caller, or an empty string when anonymous.
hook: Option<extern "C" fn(ctx: *mut c_void) -> *mut c_char>Lifecycle-hook context as JSON, or an empty string for a plain HTTP call.
See HostApi::hook for the shape.
free_string: Option<extern "C" fn(ctx: *mut c_void, string: *mut c_char)>Release a string one of the callbacks above returned.
send_email: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>Send an email. request_json is the message
({"to":…,"subject":…,"text":…}); returns the receipt
{"provider":…,"id":…,"recipients":n} or {"error":"…"}. As with
query the shape distinguishes them.
See HostApi::send_email.
cache: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>Run one cache operation. request_json is {"op":"get","key":"…"} and
friends; returns the operation’s reply or {"error":"…"}.
See HostApi::cache.
payments: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>Run one payment operation. request_json is
{"op":"checkout","stripe_price_id":"…"} and friends; returns the
operation’s reply or {"error":"…"}.
See HostApi::payments.
ai: Option<extern "C" fn(ctx: *mut c_void, request_json: *const c_char) -> *mut c_char>Ask the AI assistant. request_json is a conversation
({"messages":[{"role":"user","content":"…"}]}); returns the answer
{"text":…,"provider":…,"model":…} or {"error":"…"}.
See HostApi::ai.
emit: Option<extern "C" fn(ctx: *mut c_void, chunk: *const c_char) -> i32>Push a chunk of the response to the caller before the call returns.
Returns non-zero while it is still worth producing more, and zero once
the caller has hung up. See HostApi::emit.
Auto Trait Implementations§
impl !Send for Host
impl !Sync for Host
impl Freeze for Host
impl RefUnwindSafe for Host
impl Unpin for Host
impl UnsafeUnpin for Host
impl UnwindSafe for Host
Blanket Implementations§
Source§impl<T> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo* type which aligns Self to ALIGNMENT.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
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read more