Struct safe_drive::context::Context
source · pub struct Context { /* private fields */ }
Expand description
Context of ROS2.
Implementations§
source§impl Context
impl Context
sourcepub fn new() -> Result<Arc<Self>, DynError>
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();
sourcepub fn create_node(
self: &Arc<Self>,
name: &str,
namespace: Option<&str>,
options: NodeOptions,
) -> RCLResult<Arc<Node>>
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, orRCLError::NotInit
if the given context is invalid, orRCLError::InvalidArgument
if any arguments are invalid, orRCLError::BadAlloc
if allocating memory failed, orRCLError::NodeInvalidName
if the name is invalid, orRCLError::NodeInvalidNamespace
if the namespace_ is invalid, orRCLError::Error
if an unspecified error occurs.
sourcepub fn create_selector(self: &Arc<Self>) -> RCLResult<Selector>
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, orRCLError::NotInit
if the given context is invalid, orRCLError::InvalidArgument
if any arguments are invalid, orRCLError::BadAlloc
if allocating memory failed, orRCLError::WaitSetInvalid
if the wait set is not destroyed properly, orRCLError::Error
if an unspecified error occurs.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Context
impl RefUnwindSafe for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more