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>
impl<TIn: DdsType + Send + 'static, TOut: DdsType + Send + 'static> Requester<TIn, TOut>
Sourcepub fn new(
participant: &DomainParticipant,
service_name: &str,
qos: &RpcQos,
) -> RpcResult<Self>
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::InvalidServiceNameif the name is empty/illegal.RpcError::Dcpson topic/writer/reader creation errors.RpcError::DuplicateInstanceNameif a requester/replier with the same(service, instance)pair already runs on the same participant.
Sourcepub fn with_instance(
participant: &DomainParticipant,
service_name: &str,
instance_name: &str,
qos: &RpcQos,
) -> RpcResult<Self>
pub fn with_instance( participant: &DomainParticipant, service_name: &str, instance_name: &str, qos: &RpcQos, ) -> RpcResult<Self>
Sourcepub fn service_name(&self) -> &str
pub fn service_name(&self) -> &str
Service name this requester works against.
Sourcepub fn instance_name(&self) -> &str
pub fn instance_name(&self) -> &str
Service instance name ("" if default instance).
Sourcepub fn pending_count(&self) -> usize
pub fn pending_count(&self) -> usize
Number of outstanding requests.
Sourcepub fn default_timeout(&self) -> Duration
pub fn default_timeout(&self) -> Duration
Current default-timeout configuration.
Sourcepub fn send_request_async(
&self,
payload: &TIn,
) -> RpcResult<(SampleIdentity, Receiver<ReplyOutcome>)>
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.
Sourcepub fn send_oneway(&self, payload: &TIn) -> RpcResult<SampleIdentity>
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.
Sourcepub fn send_request_blocking(
&self,
payload: &TIn,
timeout: Option<Duration>,
) -> RpcResult<TOut>
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::Timeoutif no reply arrived duringtimeout.RpcError::RemoteException(code)if the server side reported aRemoteExceptionCode != Ok.RpcError::Dcpson encode/decode/writer errors.