Skip to main content

Host

Struct Host 

Source
pub struct Host { /* private fields */ }
Expand description

The host for one run.

Implementations§

Source§

impl Host

Source

pub fn context(&self) -> Result<Context>

The run’s context: schedule, run, rule set, source, pipeline, last success, options.

Source

pub fn context_json(&self) -> Result<Json>

The context as the host sent it.

Source

pub fn store_raw( &self, name: &str, format: &str, bytes: &[u8], ) -> Result<String>

Store one raw item (kept byte for byte, never parsed) in the run’s source; returns its id. format is a hint for the pipeline: csv, json, ndjson, text, bytes.

Source

pub fn pipe(&self) -> Result<Piped>

Run the schedule’s pipeline over this run’s raw items.

Source

pub fn run_ruleset(&self, ruleset_id: Option<&str>) -> Result<RulesetRun>

Record connector.run and run a rule set (None: the schedule’s).

Source

pub fn fetch(&self, req: &Request) -> Result<Response>

HTTP through the host’s client (its user agent, timeouts and retries).

Source

pub fn state_get(&self, key: &str) -> Result<Option<Json>>

A value of the schedule’s small state (a cursor such as the last timestamp).

Source

pub fn state_set(&self, key: &str, value: impl Into<Json>) -> Result<()>

Set (or with Json::Null, remove) a state value; kept only when the run succeeds.

Source§

impl Host

Source

pub unsafe fn from_raw(raw: *const WnHost) -> Result<Host>

§Safety

raw must be the host table passed to weirdnet_plugin_run, valid for the run.

Source

pub fn call(&self, method: &str, request: &Json) -> Result<Json>

Call a host method with a JSON request.

Source

pub fn methods(&self) -> Result<Vec<String>>

The host methods this host knows.

Source

pub fn input(&self) -> Result<Frame>

Records as the code space’s input says (model, filters, grouping, sorting).

Source

pub fn input_json(&self) -> Result<Json>

The input as the host sent it (a frame’s JSON), to hand on to Host::call_code.

Source

pub fn call_code(&self, alias: &str, input: Option<&Json>) -> Result<Frame>

A code space’s main calls a member by its alias (declared in an @imports alias header) over input (a frame’s JSON; None: the member’s own default input). Returns the member’s output frame. Only main may call.

Source

pub fn call_space(&self, name: &str, input: Option<&Json>) -> Result<Frame>

A code space’s main runs another space (its main), declared as @imports space:NAME. Returns its output frame. Spaces nest at most 8 deep, no loops.

Source

pub fn inputs(&self) -> Result<Vec<String>>

The names of the inputs, when several feed this run (a pipeline’s fan-in).

Source

pub fn input_named(&self, name: &str) -> Result<Frame>

One input by name (a pipeline’s fan-in: the upstream node’s id, or the edge’s name).

Source

pub fn options(&self) -> Vec<(String, String)>

The step’s options, as text: code:to-bars?symbol=BTC/USDT&duration=5m gives [("symbol", "BTC/USDT"), ("duration", "5m")]. Empty when none were given (or the host is older than options).

Source

pub fn option(&self, name: &str) -> Option<String>

One option by name (see Host::options).

Source

pub fn input_request(&self) -> Result<Json>

The code space’s input request itself (what Host::input loads).

Source

pub fn models(&self) -> Result<Json>

Every model with its fields: [{"name": "signals", "version": 2, "fields": [{"name", "type", "ref"}]}].

Source

pub fn load(&self, q: &Load) -> Result<Frame>

Load records.

Source

pub fn update(&self, model: &str, id: &str, values: Json) -> Result<()>

Change one record by id: values is an object of FIELD: VALUE.

Source

pub fn update_where( &self, model: &str, conditions: &[&str], values: Json, ) -> Result<usize>

Change every record matching all conditions (price > 3); returns how many.

Source

pub fn update_each( &self, model: &str, updates: Vec<(String, Json)>, ) -> Result<usize>

Change many records, each by id with its own values (one history entry).

Source

pub fn create(&self, model: &str, values: Json) -> Result<String>

Create a record; returns its id.

Source

pub fn create_many( &self, model: &str, records: Vec<Json>, ) -> Result<Vec<String>>

Create many records (one history entry); returns their ids.

Source

pub fn create_model( &self, name: &str, fields: &str, about: &str, ) -> Result<bool>

Create a model with the designer’s field syntax ("symbol:text!; score:real; idea:ref:ideas"), applied as v1. Nothing happens if it exists already (returns false).

Source

pub fn log(&self, text: impl Into<String>)

A line for the run log (shown with the result, never printed by the host).

Auto Trait Implementations§

§

impl !Send for Host

§

impl !Sync for Host

§

impl Forget for Host

§

impl Freeze for Host

§

impl Move for Host

§

impl RefUnwindSafe for Host

§

impl Unpin for Host

§

impl UnsafeUnpin for Host

§

impl UnwindSafe for Host

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.