Browse Source

Adding Rust docstring documentation

tags/v0.2.3^2
haixuanTao 3 years ago
parent
commit
f9d8fac8e5
4 changed files with 52 additions and 0 deletions
  1. +1
    -0
      apis/rust/node/src/event_stream/mod.rs
  2. +15
    -0
      apis/rust/node/src/lib.rs
  3. +19
    -0
      apis/rust/node/src/node/mod.rs
  4. +17
    -0
      apis/rust/operator/src/lib.rs

+ 1
- 0
apis/rust/node/src/event_stream/mod.rs View File

@@ -85,6 +85,7 @@ impl EventStream {
})
}

/// wait for the next event on the events stream.
pub fn recv(&mut self) -> Option<Event> {
let event = self.receiver.recv();
self.recv_common(event)


+ 15
- 0
apis/rust/node/src/lib.rs View File

@@ -1,3 +1,18 @@
//! The custom node API allow you to integrate `dora` into your application.
//! It allows you to retrieve input and send output in any fashion you want.
//!
//! Try it out with:
//!
//! ```bash
//! dora new node --kind node
//! ```
//!
//! You can also generate a dora rust project with
//!
//! ```bash
//! dora new project_xyz --kind dataflow
//! ```
//!
pub use dora_core;
pub use dora_core::message::{uhlc, Metadata, MetadataParameters};
pub use event_stream::{Data, Event, EventStream, MappedInputData};


+ 19
- 0
apis/rust/node/src/node/mod.rs View File

@@ -34,6 +34,12 @@ pub struct DoraNode {
}

impl DoraNode {
/// Initiate a node from environment variables set by `dora-coordinator`
///
/// ```rust
/// let (mut node, mut events) = DoraNode::init_from_env()?;
/// ```
///
pub fn init_from_env() -> eyre::Result<(Self, EventStream)> {
let node_config: NodeConfig = {
let raw = std::env::var("DORA_NODE_CONFIG")
@@ -74,6 +80,19 @@ impl DoraNode {
Ok((node, event_stream))
}

/// Send data from the node to the other nodes.
/// We take a closure as an input to enable zero copy on send.
///
/// ```rust
/// node.send_output(
/// &data_id,
/// metadata.parameters,
/// data.len(),
/// |out| {
/// out.copy_from_slice(data);
/// })?;
/// ```
///
pub fn send_output<F>(
&mut self,
output_id: DataId,


+ 17
- 0
apis/rust/operator/src/lib.rs View File

@@ -1,3 +1,20 @@
//! The operator API is a framework to implement dora operators.
//! The implemented operator will be managed by `dora`.
//!
//! This framework enable us to make optimisation and provide advanced features.
//! It is the recommended way of using `dora`.
//!
//! An operator requires to be registered and implement the `DoraOperator` trait.
//! It is composed of an `on_event` method that defines the behaviour
//! of the operator when there is an event such as receiving an input for example.
//!
//! Try it out with:
//!
//! ```bash
//! dora new op --kind operator
//! ```
//!

#![warn(unsafe_op_in_unsafe_fn)]
#![allow(clippy::missing_safety_doc)]



Loading…
Cancel
Save