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