Expand description
The plugin SDK: implement one of Source, Format or Destination and call the
matching serve_* function from main. The SDK owns stdin/stdout, the handshake, framing,
request ids, error replies and panics.
Formats and destinations declare their options (options()) and add any rule a declaration
can’t express (validate()). The SDK checks a config block against both on validate and
before every write and deliver, so plugin code only sees options that passed.
- Logging: use the
logcrate (log::info!,log::warn!), or [log] for a message with fields; the SDK sends them to core aslogmessages. The plugin’s own records keep their level; its dependencies’ are shown only with-v. Long requests may reportprogress. - Errors: return a
PluginErrorto give core the problem’s kind and code; any other error is sent as a plain message. - Cancellation: stdin is read on a background thread while a request runs. On
cancel(or when core goes away)cancelledturns true and the hook set withon_cancelruns, e.g. to cancel a query on the server.
Structs§
- About
- Identity reported in the handshake.
- Delivery
- A destination
deliverrequest. - Delivery
File - One file to deliver: the local copy in
target/run/and its rendered remote path, if any. - Input
- The frames core sends, read on a background thread (see [
read_stdin]). - Loaded
- The outcome of
Source::load. - Plugin
Error - An error with its kind and, optionally, a code. The SDK namespaces the code by the plugin
(
host-key-mismatchis sent assftp/host-key-mismatch). - Result
Set - One incoming result set, streamed from core.
- Result
Sets - Hands a format plugin its result sets one at a time, in order.
- Write
Request - A format
writerequest.
Enums§
- Error
Kind - What kind of problem a
PluginErroris (the kinds of DRE’s error-code registry). - Plugin
- One of the plugins a package’s executable serves (see
serve_package).
Traits§
- Destination
- Format
- Result
Sink - Where a source pushes the outcome of
execute: eitherno_result, orbeginfollowed by any number ofbatchcalls. - Source
Functions§
- cancelled
- Whether core has cancelled the request running now. Long loops check it between steps.
- conn_
bool - Read a flag that may be written as a boolean or a string.
- conn_
required - Read a required string field from a connection map.
- conn_
str - Read a string field from a connection map.
- log
- Send a log message to core.
- log_
fields - Send a log message to core, with structured
fields(never secrets). - on_
cancel - Run
hookwhen core cancels a request, on the stdin reader’s thread, while the request is still running on the main one (e.g. ask the server to cancel the query). Replaces any hook set before. The request then fails, and the SDK replies with kindcancelled. - progress
- Tell core how far a long request has got; it shows the latest.
- serve_
destination - serve_
format - serve_
package - Serve every plugin of a package from one executable. Core’s
hellonames the plugin it wants; without one, the first is served. - serve_
source