Skip to main content

Requester

Struct Requester 

Source
pub struct Requester<TIn: DdsType, TOut: DdsType> { /* private fields */ }
Expand description

Client side of a DDS-RPC service.

TIn is the user request payload type (e.g. Calculator_AddRequest), TOut the user reply payload type. Both must implement DdsType — encoding/decoding goes through DdsType::encode and DdsType::decode.

Implementations§

Source§

impl<TIn: DdsType + Send + 'static, TOut: DdsType + Send + 'static> Requester<TIn, TOut>

Source

pub fn new( participant: &DomainParticipant, service_name: &str, qos: &RpcQos, ) -> RpcResult<Self>

Creates a new requester against service_name.

Produces two topics — <service>_Request (writer) and <service>_Reply (reader) — and a Publisher/Subscriber pair. instance_name="" means “default instance, no PID_SERVICE_INSTANCE_NAME”.

§Errors
  • RpcError::InvalidServiceName if the name is empty/illegal.
  • RpcError::Dcps on topic/writer/reader creation errors.
  • RpcError::DuplicateInstanceName if a requester/replier with the same (service, instance) pair already runs on the same participant.
Source

pub fn with_instance( participant: &DomainParticipant, service_name: &str, instance_name: &str, qos: &RpcQos, ) -> RpcResult<Self>

Like Self::new, but with an explicit service_instance_name (Spec §7.8.2 PID 0x0080).

§Errors

See Self::new.

Source

pub fn service_name(&self) -> &str

Service name this requester works against.

Source

pub fn instance_name(&self) -> &str

Service instance name ("" if default instance).

Source

pub fn pending_count(&self) -> usize

Number of outstanding requests.

Source

pub fn default_timeout(&self) -> Duration

Current default-timeout configuration.

Source

pub fn send_request_async( &self, payload: &TIn, ) -> RpcResult<(SampleIdentity, Receiver<ReplyOutcome>)>

Sends a request without waiting for a reply. Returns an mpsc::Receiver through which the caller later picks up the reply with mpsc::Receiver::recv (or a self-driven tick() loop).

§Errors

RpcError::Dcps on encoder or writer errors.

Source

pub fn send_oneway(&self, payload: &TIn) -> RpcResult<SampleIdentity>

Sends a oneway request — no reply expected, no pending slot.

§Errors

RpcError::Dcps on encoder or writer errors.

Source

pub fn send_request_blocking( &self, payload: &TIn, timeout: Option<Duration>, ) -> RpcResult<TOut>

Sends a request and blocks until reply or timeout.

timeout=None uses RpcQos::request_timeout; override explicitly via Some(...).

§Errors
  • RpcError::Timeout if no reply arrived during timeout.
  • RpcError::RemoteException(code) if the server side reported a RemoteExceptionCode != Ok.
  • RpcError::Dcps on encode/decode/writer errors.
Source

pub fn tick(&self)

Reads new replies from the reader, correlates via related_request_id, and fires the associated mpsc::Sender. Idempotent (no reply ⇒ no-op).

Trait Implementations§

Source§

impl<TIn: DdsType, TOut: DdsType> Debug for Requester<TIn, TOut>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<TIn, TOut> !Freeze for Requester<TIn, TOut>

§

impl<TIn, TOut> !RefUnwindSafe for Requester<TIn, TOut>

§

impl<TIn, TOut> !UnwindSafe for Requester<TIn, TOut>

§

impl<TIn, TOut> Send for Requester<TIn, TOut>

§

impl<TIn, TOut> Sync for Requester<TIn, TOut>

§

impl<TIn, TOut> Unpin for Requester<TIn, TOut>

§

impl<TIn, TOut> UnsafeUnpin for Requester<TIn, TOut>

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.