Skip to content

struct

Spec

pub struct Spec {
    pub src: String,
    pub format: Option<Format>,
    pub path: Option<String>,
    pub query: Option<String>,
    pub variables: Option<Value>,
    pub method: Option<String>,
    pub body: Option<String>,
    pub params: Option<Value>,
    pub load: Option<Load>,
    pub refresh: Option<f64>,
    pub missing: Vec<String>,
    pub filter: Option<BTreeMap<String, Value>>,
    pub sort: Option<String>,
    pub limit: Option<usize>,
    pub group_by: Option<String>,
    pub group_within: Vec<String>,
    pub aggregate: Option<String>,
    pub live: Option<String>,
    pub live_path: Option<String>,
    pub event: Option<String>,
    pub subscription: Option<String>,
    pub update: Option<Update>,
    pub row_key: Option<String>,
    pub keep: Option<usize>,
    pub preset: Option<String>,
    pub skip: Option<String>,
    pub header_rows: Option<usize>,
    pub footer: Option<usize>,
    pub sheet: Option<String>,
    pub melt: Option<Vec<String>>,
    pub labels: Option<String>,
    pub paginate: bool,
}

What a component's src and related props ask for.

Fields

src

pub src: String

Where the data is.

format

pub format: Option<Format>

Its format, when it can't be told from the URL or response.

path

pub path: Option<String>

Where the rows are in a JSON response.

query

pub query: Option<String>

A GraphQL query, sent as a POST.

variables

pub variables: Option<Value>

The GraphQL query's variables.

method

pub method: Option<String>

The HTTP method, when it isn't GET.

body

pub body: Option<String>

The request body.

params

pub params: Option<Value>

Query parameters added to src.

load

pub load: Option<Load>

When to load: during the build, in the browser, or both.

refresh

pub refresh: Option<f64>

Reload every this many seconds.

missing

pub missing: Vec<String>

Markers that mean "no value", besides the usual ones (np, ..).

filter

pub filter: Option<BTreeMap<String, Value>>

Keep only rows whose fields have these values.

sort

pub sort: Option<String>

The column to sort by (-key for descending).

limit

pub limit: Option<usize>

Keep only this many rows.

group_by

pub group_by: Option<String>

The column to group rows by.

group_within

pub group_within: Vec<String>

Columns a group_by keeps apart: what the chart splits on anyway.

aggregate

pub aggregate: Option<String>

How a group's values are combined (sum unless given).

live

pub live: Option<String>

Where updates arrive: wss:// is a WebSocket, anything else server-sent events.

live_path

pub live_path: Option<String>

Where the rows are in a live message.

event

pub event: Option<String>

The type of server-sent event to listen for.

subscription

pub subscription: Option<String>

A GraphQL subscription, over a WebSocket.

update

pub update: Option<Update>

What a live update does to the rows: replace them, append, or upsert.

row_key

pub row_key: Option<String>

What identifies a row, for upsert.

keep

pub keep: Option<usize>

How many rows to hold on to: the most recent.

preset

pub preset: Option<String>

The layout of an export: qualtrics, surveymonkey, tablebuilder.

skip

pub skip: Option<String>

Rows to drop from the top, or auto to find the table.

header_rows

pub header_rows: Option<usize>

How many rows the header takes.

footer

pub footer: Option<usize>

Rows to drop from the end.

sheet

pub sheet: Option<String>

Which sheet of a workbook.

melt

pub melt: Option<Vec<String>>

Columns to turn into variable and value rows: true for every number column.

labels

pub labels: Option<String>

A codebook to label coded values with.

paginate

pub paginate: bool

Follow an API's pages to the end.

Methods

from_props

pub fn from_props(get: impl Fn(&str) -> Option<Value>) -> Option<Spec>

Read the props (None when there's no src).

when

pub fn when(&self) -> Load

When to load: as asked, or what suits the source.

key

pub fn key(&self) -> String

Identifies the request, so components asking for the same data share one load (shaping happens per component).

fetches

pub fn fetches(&self) -> bool

Whether there's anything to load before updates start. A subscription's src is only where to connect, unless a query gives it a first load.

stats_option

pub fn stats_option(&self) -> Option<&'static str>

A set option that needs the stats feature.

is_live

pub fn is_live(&self) -> bool

Whether updates arrive by themselves.

connection

pub fn connection(&self) -> Option<Connect>

Where to connect for updates.

update_mode

pub fn update_mode(&self) -> Update

How a live message applies: upsert given a key, else append.

problem

pub fn problem(&self) -> Option<String>

A mistake in the props that would send the wrong request, said in a way that fixes it. query is a GraphQL query, and a value like startPeriod=2026-06 is meant as the URL's query string: sent as GraphQL, it becomes a JSON POST that APIs reject (often as a baffling CORS error, since the JSON header needs a preflight).

request

pub fn request(&self) -> Request

The request to make.

Trait implementations