Skip to main content

ZeroOptions

Struct ZeroOptions 

Source
pub struct ZeroOptions {
Show 22 fields pub cache_url: Option<String>, pub user_id: Option<String>, pub auth: Option<String>, pub storage_key: Option<String>, pub ping_timeout_ms: f64, pub disconnect_timeout_ms: f64, pub query_change_throttle_ms: f64, pub max_header_length: usize, pub mutate_url: Option<String>, pub mutate_headers: Option<Vec<(String, String)>>, pub query_url: Option<String>, pub query_headers: Option<Vec<(String, String)>>, pub on_update_needed: Option<UpdateNeededHandler>, pub on_client_state_not_found: Option<Rc<dyn Fn()>>, pub storage: ZeroStorage, pub on_storage_failure: Option<StorageFailureHandler>, pub log_level: LogLevel, pub log_sink: Option<Rc<dyn LogSink>>, pub hidden_disconnect_delay_ms: f64, pub get_traceparent: Option<Rc<dyn Fn() -> Option<String>>>, pub batch_view_updates: Option<BatchViewUpdates>, pub slow_materialize_threshold_ms: f64,
}
Expand description

The options of a Zero client (ZeroOptions in packages/zero-client/src/client/options.ts).

Fields§

§cache_url: Option<String>

The zero-cache URL, http or https. Without one the client runs locally and never connects.

§user_id: Option<String>

The user the client syncs for. None for a logged-out client.

§auth: Option<String>

The auth token zero-cache and the API server see.

§storage_key: Option<String>

Distinguishes local stores of the same user and URLs.

§ping_timeout_ms: f64

How long the client waits for a pong before it reconnects.

§disconnect_timeout_ms: f64

How long the client tries to reconnect before the state is Disconnected.

§query_change_throttle_ms: f64

How long query changes are batched before they are sent.

§max_header_length: usize

The longest Sec-WebSocket-Protocol header the client sends. initConnection is sent as a message instead when it doesn’t fit.

§mutate_url: Option<String>

The API server’s push URL, when it differs from the one zero-cache is configured with.

§mutate_headers: Option<Vec<(String, String)>>

Headers zero-cache sends to mutate_url.

§query_url: Option<String>

The API server’s query URL, when it differs from the one zero-cache is configured with.

§query_headers: Option<Vec<(String, String)>>

Headers zero-cache sends to query_url.

§on_update_needed: Option<UpdateNeededHandler>

The server needs a newer client. Defaults to doing nothing.

§on_client_state_not_found: Option<Rc<dyn Fn()>>

The server no longer has the client’s state, or the stored replica didn’t decode and the local store was reset. Without it, a client the server lost replaces itself by a new one on the same store, as JS reloads the page (see Zero::new).

§storage: ZeroStorage

Where the client keeps its replica. Defaults to ZeroStorage::Memory, which keeps nothing across restarts.

§on_storage_failure: Option<StorageFailureHandler>

The local store failed, so the client runs on what it has in memory and persists nothing more (onStorageFailure). Called once.

§log_level: LogLevel

The least severe messages logged.

§log_sink: Option<Rc<dyn LogSink>>

Where messages are logged. Defaults to StderrLogSink.

§hidden_disconnect_delay_ms: f64

How long the app is hidden before the client disconnects (hiddenTabDisconnectDelay); see Zero::set_visible. 5 minutes by default, as in JS. A mobile app, which the system suspends soon after it goes to the background, can set 0 to disconnect as soon as it is hidden.

§get_traceparent: Option<Rc<dyn Fn() -> Option<String>>>

A W3C traceparent for each query change and push the client sends (getTraceparent), so zero-cache and the API server can join the app’s trace. Called once per message; None sends none.

§batch_view_updates: Option<BatchViewUpdates>

Wraps every update of the views (batchViewUpdates), for a UI that renders a batch of state changes at once: each new view’s creation, and each change that updates the views (a poke, a mutation, the first hydration), with its listener calls. It must call the function it is given, once, before it returns.

§slow_materialize_threshold_ms: f64

How long, in ms, a query may take to materialize, including the server’s and the network’s time, before the client logs a warning (slowMaterializeThreshold). Faster materializations are logged at debug level.

Trait Implementations§

Source§

impl Clone for ZeroOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for ZeroOptions

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.