#[non_exhaustive]pub struct DittoConfig {
pub database_id: String,
pub connect: DittoConfigConnect,
pub persistence_directory: Option<PathBuf>,
pub system_parameters: HashMap<String, Value>,
/* private fields */
}Expand description
Configuration options required to initialize a Ditto instance.
§Example
const YOUR_DATABASE_ID: &str = "REPLACE ME WITH YOUR APP/DATABASE ID";
const YOUR_AUTH_URL: &str = "https://your-app.cloud.ditto.live";
const YOUR_PRIVATE_KEY: &str = "REPLACE ME WITH YOUR PRIVATE KEY";
let connect = DittoConfigConnect::Server {
url: YOUR_AUTH_URL.parse().unwrap(),
};
let connect = DittoConfigConnect::SmallPeersOnly {
private_key: Some(YOUR_PRIVATE_KEY.as_bytes().to_vec()),
};
let connect = DittoConfigConnect::SmallPeersOnly { private_key: None };
let config = DittoConfig::new(YOUR_DATABASE_ID, connect);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.database_id: StringAn ID used to distinguish between Ditto database instantiations.
Note: This was formerly known as appId.
connect: DittoConfigConnectThe connection configuration this device uses to connect to a Ditto mesh.
persistence_directory: Option<PathBuf>The directory where Ditto will store its data.
system_parameters: HashMap<String, Value>System parameter overrides applied before Ditto initializes its subsystems.
Each key is a system parameter name. Names are case-insensitive. Each value must match the
parameter’s Core-defined type and validation rules. The supported serde_json::Value
shapes are:
- booleans and strings;
- nonnegative integers through
u64::MAX, negative integers throughi64::MIN, and finite floating-point numbers; and - arrays and string-keyed objects containing those values recursively.
Nonnegative integers are normalized to Core’s unsigned integer representation, regardless
of whether they were constructed from a signed or unsigned Rust integer. JSON null is not
a system parameter type and is rejected, including inside arrays and objects. Binary values
and CBOR tags cannot be represented by serde_json::Value.
Unsupported SDK value shapes, such as JSON null, return
ErrorKind::InvalidInput. Unknown parameter
names, values of the wrong type, and values outside a parameter’s valid range cause
Ditto::open and
Ditto::open_sync to return
CoreApiErrorKind::ValidationInvalidDittoConfig.
Implementations§
Source§impl DittoConfig
impl DittoConfig
Sourcepub fn new<S: Into<String>>(database_id: S, connect: DittoConfigConnect) -> Self
pub fn new<S: Into<String>>(database_id: S, connect: DittoConfigConnect) -> Self
Create a new DittoConfig instance from a database ID and connection configuration.
Sourcepub fn with_persistence_directory<P: Into<PathBuf>>(self, path: P) -> Self
pub fn with_persistence_directory<P: Into<PathBuf>>(self, path: P) -> Self
Optionally specify a custom persistence directory.
Trait Implementations§
Source§impl Clone for DittoConfig
impl Clone for DittoConfig
Source§fn clone(&self) -> DittoConfig
fn clone(&self) -> DittoConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more