Remove private items docs
This commit is contained in:
parent
1a699720ae
commit
9705c0ef59
|
@ -61,22 +61,19 @@ unsafe impl<State: WakuNodeState> Sync for WakuNodeHandle<State> {}
|
||||||
|
|
||||||
impl<State: WakuNodeState> WakuNodeHandle<State> {
|
impl<State: WakuNodeState> WakuNodeHandle<State> {
|
||||||
/// If the execution is successful, the result is the peer ID as a string (base58 encoded)
|
/// If the execution is successful, the result is the peer ID as a string (base58 encoded)
|
||||||
///
|
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop)
|
||||||
/// wrapper around [`management::waku_peer_id`]
|
|
||||||
pub fn peer_id(&self) -> Result<PeerId> {
|
pub fn peer_id(&self) -> Result<PeerId> {
|
||||||
management::waku_peer_id()
|
management::waku_peer_id()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the multiaddresses the Waku node is listening to
|
/// Get the multiaddresses the Waku node is listening to
|
||||||
///
|
/// as per [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_listen_addresses)
|
||||||
/// wrapper around [`management::waku_listen_addresses`]
|
|
||||||
pub fn listen_addresses(&self) -> Result<Vec<Multiaddr>> {
|
pub fn listen_addresses(&self) -> Result<Vec<Multiaddr>> {
|
||||||
management::waku_listen_addresses()
|
management::waku_listen_addresses()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a node multiaddress and protocol to the waku node’s peerstore
|
/// Add a node multiaddress and protocol to the waku node’s peerstore.
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_add_peerchar-address-char-protocolid)
|
||||||
/// wrapper around [`peers::waku_add_peers`]
|
|
||||||
pub fn add_peer(&self, address: &Multiaddr, protocol_id: ProtocolId) -> Result<PeerId> {
|
pub fn add_peer(&self, address: &Multiaddr, protocol_id: ProtocolId) -> Result<PeerId> {
|
||||||
peers::waku_add_peers(address, protocol_id)
|
peers::waku_add_peers(address, protocol_id)
|
||||||
}
|
}
|
||||||
|
@ -91,16 +88,14 @@ fn stop_node() -> Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WakuNodeHandle<Initialized> {
|
impl WakuNodeHandle<Initialized> {
|
||||||
/// Start a Waku node mounting all the protocols that were enabled during the Waku node instantiation
|
/// Start a Waku node mounting all the protocols that were enabled during the Waku node instantiation.
|
||||||
///
|
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_start)
|
||||||
/// wrapper around [`management::waku_start`]
|
|
||||||
pub fn start(self) -> Result<WakuNodeHandle<Running>> {
|
pub fn start(self) -> Result<WakuNodeHandle<Running>> {
|
||||||
management::waku_start().map(|_| WakuNodeHandle(Default::default()))
|
management::waku_start().map(|_| WakuNodeHandle(Default::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Stops a Waku node
|
/// Stops a Waku node
|
||||||
///
|
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop)
|
||||||
/// internally uses [`management::waku_stop`]
|
|
||||||
pub fn stop(self) -> Result<()> {
|
pub fn stop(self) -> Result<()> {
|
||||||
stop_node()
|
stop_node()
|
||||||
}
|
}
|
||||||
|
@ -108,8 +103,7 @@ impl WakuNodeHandle<Initialized> {
|
||||||
|
|
||||||
impl WakuNodeHandle<Running> {
|
impl WakuNodeHandle<Running> {
|
||||||
/// Stops a Waku node
|
/// Stops a Waku node
|
||||||
///
|
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_stop)
|
||||||
/// internally uses [`management::waku_stop`]
|
|
||||||
pub fn stop(self) -> Result<()> {
|
pub fn stop(self) -> Result<()> {
|
||||||
stop_node()
|
stop_node()
|
||||||
}
|
}
|
||||||
|
@ -118,8 +112,7 @@ impl WakuNodeHandle<Running> {
|
||||||
/// If `timeout` as milliseconds doesn't fit into a `i32` it is clamped to [`i32::MAX`]
|
/// If `timeout` as milliseconds doesn't fit into a `i32` it is clamped to [`i32::MAX`]
|
||||||
/// If the function execution takes longer than `timeout` value, the execution will be canceled and an error returned.
|
/// If the function execution takes longer than `timeout` value, the execution will be canceled and an error returned.
|
||||||
/// Use 0 for no timeout
|
/// Use 0 for no timeout
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_connect_peerchar-address-int-timeoutms)
|
||||||
/// wrapper around [`peers::waku_connect_peer_with_address`]
|
|
||||||
pub fn connect_peer_with_address(
|
pub fn connect_peer_with_address(
|
||||||
&self,
|
&self,
|
||||||
address: &Multiaddr,
|
address: &Multiaddr,
|
||||||
|
@ -128,37 +121,35 @@ impl WakuNodeHandle<Running> {
|
||||||
peers::waku_connect_peer_with_address(address, timeout)
|
peers::waku_connect_peer_with_address(address, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Dial peer using its peer ID
|
/// Dial peer using a peer id
|
||||||
///
|
/// If `timeout` as milliseconds doesn't fit into a `i32` it is clamped to [`i32::MAX`]
|
||||||
/// wrapper around [`peers::waku_connect_peer_with_id`]
|
/// The peer must be already known.
|
||||||
|
/// It must have been added before with [`WakuNodeHandle::add_peer`] or previously dialed with [`WakuNodeHandle::connect_peer_with_address`]
|
||||||
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_connect_peeridchar-peerid-int-timeoutms)
|
||||||
pub fn connect_peer_with_id(&self, peer_id: PeerId, timeout: Option<Duration>) -> Result<()> {
|
pub fn connect_peer_with_id(&self, peer_id: PeerId, timeout: Option<Duration>) -> Result<()> {
|
||||||
peers::waku_connect_peer_with_id(peer_id, timeout)
|
peers::waku_connect_peer_with_id(peer_id, timeout)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnect a peer using its peerID
|
/// Disconnect a peer using its peer id
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_disconnect_peerchar-peerid)
|
||||||
/// wrapper around [`peers::waku_disconnect_peer_with_id`]
|
|
||||||
pub fn disconnect_peer_with_id(&self, peer_id: &PeerId) -> Result<()> {
|
pub fn disconnect_peer_with_id(&self, peer_id: &PeerId) -> Result<()> {
|
||||||
peers::waku_disconnect_peer_with_id(peer_id)
|
peers::waku_disconnect_peer_with_id(peer_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get number of connected peers
|
/// Get number of connected peers
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_peer_count)
|
||||||
/// wrapper around [`peers::waku_peer_count`]
|
|
||||||
pub fn peer_count(&self) -> Result<usize> {
|
pub fn peer_count(&self) -> Result<usize> {
|
||||||
peers::waku_peer_count()
|
peers::waku_peer_count()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieve the list of peers known by the Waku node
|
/// Retrieve the list of peers known by the Waku node
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_peers)
|
||||||
/// wrapper around [`peers::waku_peers`]
|
|
||||||
pub fn peers(&self) -> Result<WakuPeers> {
|
pub fn peers(&self) -> Result<WakuPeers> {
|
||||||
peers::waku_peers()
|
peers::waku_peers()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Publish a message using Waku Relay
|
/// Publish a message using Waku Relay
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_relay_publishchar-messagejson-char-pubsubtopic-int-timeoutms)
|
||||||
/// wrapper around [`relay::waku_relay_publish_message`]
|
|
||||||
pub fn relay_publish_message(
|
pub fn relay_publish_message(
|
||||||
&self,
|
&self,
|
||||||
message: &WakuMessage,
|
message: &WakuMessage,
|
||||||
|
@ -169,8 +160,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optionally sign, encrypt using asymmetric encryption and publish a message using Waku Relay
|
/// Optionally sign, encrypt using asymmetric encryption and publish a message using Waku Relay
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_relay_publish_enc_asymmetricchar-messagejson-char-pubsubtopic-char-publickey-char-optionalsigningkey-int-timeoutms)
|
||||||
/// wrapper around [`relay::waku_relay_publish_encrypt_asymmetric`]
|
|
||||||
pub fn relay_publish_encrypt_asymmetric(
|
pub fn relay_publish_encrypt_asymmetric(
|
||||||
&self,
|
&self,
|
||||||
message: &WakuMessage,
|
message: &WakuMessage,
|
||||||
|
@ -189,8 +179,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optionally sign, encrypt using symmetric encryption and publish a message using Waku Relay
|
/// Optionally sign, encrypt using symmetric encryption and publish a message using Waku Relay
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_relay_publish_enc_symmetricchar-messagejson-char-pubsubtopic-char-symmetrickey-char-optionalsigningkey-int-timeoutms)
|
||||||
/// wrapper around [`relay::waku_relay_publish_encrypt_symmetric`]
|
|
||||||
pub fn relay_publish_encrypt_symmetric(
|
pub fn relay_publish_encrypt_symmetric(
|
||||||
&self,
|
&self,
|
||||||
message: &WakuMessage,
|
message: &WakuMessage,
|
||||||
|
@ -209,29 +198,24 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Determine if there are enough peers to publish a message on a given pubsub topic
|
/// Determine if there are enough peers to publish a message on a given pubsub topic
|
||||||
///
|
|
||||||
/// wrapper around [`relay::waku_enough_peers`]
|
|
||||||
pub fn relay_enough_peers(&self, pubsub_topic: Option<WakuPubSubTopic>) -> Result<bool> {
|
pub fn relay_enough_peers(&self, pubsub_topic: Option<WakuPubSubTopic>) -> Result<bool> {
|
||||||
relay::waku_enough_peers(pubsub_topic)
|
relay::waku_enough_peers(pubsub_topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Subscribe to a Waku Relay pubsub topic to receive messages
|
/// Subscribe to a Waku Relay pubsub topic to receive messages
|
||||||
///
|
|
||||||
/// wrapper around [`relay::waku_relay_subscribe`]
|
|
||||||
pub fn relay_subscribe(&self, pubsub_topic: Option<WakuPubSubTopic>) -> Result<()> {
|
pub fn relay_subscribe(&self, pubsub_topic: Option<WakuPubSubTopic>) -> Result<()> {
|
||||||
relay::waku_relay_subscribe(pubsub_topic)
|
relay::waku_relay_subscribe(pubsub_topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes the pubsub subscription to a pubsub topic. No more messages will be received from this pubsub topic
|
/// Closes the pubsub subscription to a pubsub topic. No more messages will be received from this pubsub topic
|
||||||
///
|
|
||||||
/// wrapper around [`relay::waku_relay_unsubscribe`]
|
|
||||||
pub fn relay_unsubscribe(&self, pubsub_topic: Option<WakuPubSubTopic>) -> Result<()> {
|
pub fn relay_unsubscribe(&self, pubsub_topic: Option<WakuPubSubTopic>) -> Result<()> {
|
||||||
relay::waku_relay_unsubscribe(pubsub_topic)
|
relay::waku_relay_unsubscribe(pubsub_topic)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Retrieves historical messages on specific content topics
|
/// Retrieves historical messages on specific content topics. This method may be called with [`PagingOptions`](`crate::general::PagingOptions`),
|
||||||
///
|
/// to retrieve historical messages on a per-page basis. If the request included [`PagingOptions`](`crate::general::PagingOptions`),
|
||||||
/// wrapper around [`store::waku_store_query`]
|
/// the node must return messages on a per-page basis and include [`PagingOptions`](`crate::general::PagingOptions`) in the response.
|
||||||
|
/// These [`PagingOptions`](`crate::general::PagingOptions`) must contain a cursor pointing to the Index from which a new page can be requested
|
||||||
pub fn store_query(
|
pub fn store_query(
|
||||||
&self,
|
&self,
|
||||||
query: &StoreQuery,
|
query: &StoreQuery,
|
||||||
|
@ -242,8 +226,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Publish a message using Waku Lightpush
|
/// Publish a message using Waku Lightpush
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_lightpush_publishchar-messagejson-char-topic-char-peerid-int-timeoutms)
|
||||||
/// wrapper around [`lightpush::waku_lightpush_publish`]
|
|
||||||
pub fn lightpush_publish(
|
pub fn lightpush_publish(
|
||||||
&self,
|
&self,
|
||||||
message: &WakuMessage,
|
message: &WakuMessage,
|
||||||
|
@ -255,8 +238,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optionally sign, encrypt using asymmetric encryption and publish a message using Waku Lightpush
|
/// Optionally sign, encrypt using asymmetric encryption and publish a message using Waku Lightpush
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_lightpush_publish_enc_asymmetricchar-messagejson-char-pubsubtopic-char-peerid-char-publickey-char-optionalsigningkey-int-timeoutms)
|
||||||
/// wrapper around [`lightpush::waku_lightpush_publish_encrypt_asymmetric`]
|
|
||||||
pub fn lightpush_publish_encrypt_asymmetric(
|
pub fn lightpush_publish_encrypt_asymmetric(
|
||||||
&self,
|
&self,
|
||||||
message: &WakuMessage,
|
message: &WakuMessage,
|
||||||
|
@ -277,8 +259,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Optionally sign, encrypt using symmetric encryption and publish a message using Waku Lightpush
|
/// Optionally sign, encrypt using symmetric encryption and publish a message using Waku Lightpush
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_lightpush_publish_enc_symmetricchar-messagejson-char-pubsubtopic-char-peerid-char-symmetrickey-char-optionalsigningkey-int-timeoutms)
|
||||||
/// wrapper around [`lightpush::waku_lightpush_publish_encrypt_symmetric`]
|
|
||||||
pub fn lightpush_publish_encrypt_symmetric(
|
pub fn lightpush_publish_encrypt_symmetric(
|
||||||
&self,
|
&self,
|
||||||
message: &WakuMessage,
|
message: &WakuMessage,
|
||||||
|
@ -299,8 +280,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a subscription in a lightnode for messages that matches a content filter and optionally a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
/// Creates a subscription in a lightnode for messages that matches a content filter and optionally a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_subscribechar-filterjson-char-peerid-int-timeoutms)
|
||||||
/// wrapper around [`filter::waku_filter_subscribe`]
|
|
||||||
pub fn filter_subscribe(
|
pub fn filter_subscribe(
|
||||||
&self,
|
&self,
|
||||||
filter_subscription: &FilterSubscription,
|
filter_subscription: &FilterSubscription,
|
||||||
|
@ -311,8 +291,7 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Removes subscriptions in a light node matching a content filter and, optionally, a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
/// Removes subscriptions in a light node matching a content filter and, optionally, a [`WakuPubSubTopic`](`crate::general::WakuPubSubTopic`)
|
||||||
///
|
/// As per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_filter_unsubscribechar-filterjson-int-timeoutms)
|
||||||
/// wrapper around [`filter::waku_filter_unsubscribe`]
|
|
||||||
pub fn filter_unsubscribe(
|
pub fn filter_unsubscribe(
|
||||||
&self,
|
&self,
|
||||||
filter_subscription: &FilterSubscription,
|
filter_subscription: &FilterSubscription,
|
||||||
|
@ -331,8 +310,8 @@ impl WakuNodeHandle<Running> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Spawn a new Waku node with the givent configuration (default configuration if `None` provided)
|
/// Spawn a new Waku node with the given configuration (default configuration if `None` provided)
|
||||||
/// Internally uses [`management::waku_new`]
|
/// as per the [specification](https://rfc.vac.dev/spec/36/#extern-char-waku_newchar-jsonconfig)
|
||||||
pub fn waku_new(config: Option<WakuNodeConfig>) -> Result<WakuNodeHandle<Initialized>> {
|
pub fn waku_new(config: Option<WakuNodeConfig>) -> Result<WakuNodeHandle<Initialized>> {
|
||||||
let mut node_initialized = WAKU_NODE_INITIALIZED
|
let mut node_initialized = WAKU_NODE_INITIALIZED
|
||||||
.lock()
|
.lock()
|
||||||
|
|
|
@ -28,7 +28,7 @@ pub fn waku_create_content_topic(
|
||||||
.try_into()
|
.try_into()
|
||||||
.expect("Version should fit within an u32"),
|
.expect("Version should fit within an u32"),
|
||||||
CString::new(content_topic_name)
|
CString::new(content_topic_name)
|
||||||
.expect("Conmtent topic should always transform to CString")
|
.expect("Content topic should always transform to CString")
|
||||||
.into_raw(),
|
.into_raw(),
|
||||||
CString::new(encoding.to_string())
|
CString::new(encoding.to_string())
|
||||||
.expect("Encoding should always transform to CString")
|
.expect("Encoding should always transform to CString")
|
||||||
|
|
Loading…
Reference in New Issue