Struct RuntimeBuilder

Source
pub struct RuntimeBuilder { /* private fields */ }
Expand description

Builder structure to help create a Runtime.

Most of the internals of the Runtime can left to their default values. Leveraging a builder pattern thus simplifies the creation of a Runtime.

Implementations§

Source§

impl RuntimeBuilder

Source

pub fn runtime_id(self, runtime_id: impl Into<RuntimeId>) -> Result<Self>

Forces the identifier of the Runtime to be build.

If no Session is provided, this identifier will be forced on the Session.

§Errors

This method will fail if the Zenoh feature is enabled (it is by default) and a Session was already provided. Zenoh-Flow will re-use the unique identifier of the Zenoh session for the Runtime.

⚠️ If the runtime identifier is set first and a Session is provided after, the runtime identifier will be overwritten by the identifier of the Zenoh session.

§Example
use zenoh_flow_runtime::Runtime;
use zenoh_flow_commons::RuntimeId;

let builder = Runtime::builder("demo")
    .runtime_id(RuntimeId::rand());
Source

pub fn session(self, session: Arc<Session>) -> Self

Forces the Session the Runtime should use to communicate over Zenoh.

§Runtime identifier

If a Session is provided, the Zenoh-Flow runtime will re-use the identifier of the Session as its identifier.

§Example
use zenoh_flow_runtime::Runtime;
use zenoh_flow_runtime::{zenoh, zenoh::AsyncResolve};

let zenoh_session = zenoh::open(zenoh::peer())
    .res_async()
    .await
    .expect("Failed to open Session")
    .into_arc();
let builder = Runtime::builder("demo")
    .session(zenoh_session);
Source

pub fn hlc(self, hlc: HLC) -> Self

Forces the hybrid logical clock the Runtime should use.

§Example
use zenoh_flow_runtime::Runtime;
use uhlc::HLC;

let builder = Runtime::builder("demo")
    .hlc(HLC::default());
Source

pub fn add_extensions(self, extensions: Extensions) -> Result<Self>

Attempts to add the provided Extensions to the list of extensions supported by this Runtime.

If previous extensions were already declared for the same file extension, the newly added extensions will override the previous values.

§Errors

This method will fail if any of the extension is not valid. See here for a complete list of error cases.

Note that the extensions are added after checking them all.

§Example
use zenoh_flow_runtime::{Extensions, Runtime};
use zenoh_flow_commons::{try_parse_from_file, Vars};

let (extensions, _) = try_parse_from_file::<Extensions>(
        "/home/zenoh-flow/extensions.ext",
        Vars::default()
    )
    .expect("Failed to parse Extensions");

let builder = Runtime::builder("demo")
    .add_extensions(extensions)
    .expect("Failed to add set of extensions");
Source

pub fn add_extension( self, file_extension: impl Into<String>, source: impl Into<PathBuf>, operator: impl Into<PathBuf>, sink: impl Into<PathBuf>, ) -> Result<Self>

Attempts to add a single Extension to the list of extensions supported by this Runtime.

If a previous extension was already declared for the same file extension, the newly added extension will override the previous value.

§Errors

This method will return an error if any of the library:

  • does not expose the correct symbol (see these macros: 1, 2, 3),
  • was not compiled with the same Rust version,
  • was not using the same version of Zenoh-Flow as this runtime.
§Example
use zenoh_flow_runtime::Runtime;
let builder = Runtime::builder("demo")
    .add_extension(
        "py",
        "/home/zenoh-flow/libpy_source.so",
        "/home/zenoh-flow/libpy_operator.so",
        "/home/zenoh-flow/libpy_sink.so",
    )
    .expect("Failed to add 'py' extension");
Source

pub async fn build(self) -> Result<Runtime>

Attempts to build the Runtime.

§Errors

This method can fail if the zenoh feature is enabled (it is by default), no Session was provided to the builder and the creation of a Session failed.

§Example
use zenoh_flow_runtime::Runtime;
let runtime = Runtime::builder("demo")
    .build()
    .await
    .expect("Failed to build Zenoh-Flow runtime");

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsNode<T> for T

Source§

fn as_node(&self) -> &T

Source§

impl<T> AsNodeMut<T> for T

Source§

fn as_node_mut(&mut self) -> &mut T

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SendSyncAny for T
where T: 'static + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_mut_any(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,