mirror of
https://github.com/logos-messaging/logos-messaging-rust-bindings.git
synced 2026-01-03 06:23:11 +00:00
Use optional config in waku_new
This commit is contained in:
parent
710db3aa07
commit
03187ccb6c
@ -5,7 +5,7 @@ use multiaddr::Multiaddr;
|
||||
use serde::{Deserialize, Serialize};
|
||||
// internal
|
||||
|
||||
#[derive(Serialize, Deserialize, Default)]
|
||||
#[derive(Clone, Default, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct NodeConfig {
|
||||
host: Option<std::net::IpAddr>,
|
||||
|
||||
@ -8,8 +8,9 @@ use crate::general::{JsonResponse, Result};
|
||||
|
||||
/// Instantiates a Waku node
|
||||
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_newchar-jsonconfig)
|
||||
pub fn waku_new(config: &NodeConfig) -> Result<bool> {
|
||||
let s_config = serde_json::to_string(config)
|
||||
pub fn waku_new(config: Option<NodeConfig>) -> Result<bool> {
|
||||
let config = config.unwrap_or_default();
|
||||
let s_config = serde_json::to_string(&config)
|
||||
.expect("Serialization from properly built NodeConfig should never fail");
|
||||
let result: &str = unsafe {
|
||||
CStr::from_ptr(waku_sys::waku_new(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user