Struct safe_drive::context::Context

source ·
pub struct Context { /* private fields */ }
Expand description

Context of ROS2.

Implementations§

source§

impl Context

source

pub fn new() -> Result<Arc<Self>, DynError>

Create a new context.

§Example
use safe_drive::context::Context;

// Create a context.
let ctx = Context::new().unwrap();
source

pub fn create_node( self: &Arc<Self>, name: &str, namespace: Option<&str>, options: NodeOptions ) -> RCLResult<Arc<Node>>

Create a new node of ROS2.

§Example
use safe_drive::context::Context;

// Create a context.
let ctx = Context::new().unwrap();

// Create a node.
let node = ctx
    .create_node("context_rs", None, Default::default())
    .unwrap();
§Errors
  • RCLError::AlreadyInit if the node has already be initialized, or
  • RCLError::NotInit if the given context is invalid, or
  • RCLError::InvalidArgument if any arguments are invalid, or
  • RCLError::BadAlloc if allocating memory failed, or
  • RCLError::NodeInvalidName if the name is invalid, or
  • RCLError::NodeInvalidNamespace if the namespace_ is invalid, or
  • RCLError::Error if an unspecified error occurs.
source

pub fn create_selector(self: &Arc<Self>) -> RCLResult<Selector>

Create a new selector. The selector is used to wait event and invoke callback for single threaded execution.

§Example
use safe_drive::context::Context;

// Create a context.
let ctx = Context::new().unwrap();

// Create a selector.
let selector = ctx.create_selector().unwrap();
§Errors
  • RCLError::AlreadyInit if the wait set is not zero initialized, or
  • RCLError::NotInit if the given context is invalid, or
  • RCLError::InvalidArgument if any arguments are invalid, or
  • RCLError::BadAlloc if allocating memory failed, or
  • RCLError::WaitSetInvalid if the wait set is not destroyed properly, or
  • RCLError::Error if an unspecified error occurs.

Trait Implementations§

source§

impl Drop for Context

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl Send for Context

source§

impl Sync for Context

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> 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, 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.