rclrs

Struct Service

Source
pub struct Service<T>
where T: Service,
{ pub callback: Mutex<Box<dyn Fn(&rmw_request_id_t, T::Request) -> T::Response + Send + 'static>>, /* private fields */ }
Expand description

Main class responsible for responding to requests sent by ROS clients.

The only available way to instantiate services is via Node::create_service(), this is to ensure that Nodes can track all the services that have been created.

Fields§

§callback: Mutex<Box<dyn Fn(&rmw_request_id_t, T::Request) -> T::Response + Send + 'static>>

The callback function that runs when a request was received.

Implementations§

Source§

impl<T> Service<T>
where T: Service,

Source

pub fn take_request(&self) -> Result<(T::Request, rmw_request_id_t), RclrsError>

Fetches a new request.

When there is no new message, this will return a ServiceTakeFailed.

Trait Implementations§

Source§

impl<T> ServiceBase for Service<T>
where T: Service,

Source§

fn handle(&self) -> &ServiceHandle

Internal function to get a reference to the rcl handle.
Source§

fn execute(&self) -> Result<(), RclrsError>

Tries to take a new request and run the callback with it.

Auto Trait Implementations§

§

impl<T> !Freeze for Service<T>

§

impl<T> RefUnwindSafe for Service<T>

§

impl<T> Send for Service<T>

§

impl<T> Sync for Service<T>

§

impl<T> Unpin for Service<T>

§

impl<T> UnwindSafe for Service<T>

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

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.