Skip to main content

Requester

Struct Requester 

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

Client-Seite eines DDS-RPC-Service.

TIn ist der User-Request-Payload-Typ (z.B. Calculator_AddRequest), TOut der User-Reply-Payload-Typ. Beide muessen DdsType implementieren — encodet/decodet wird ueber DdsType::encode und 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>

Legt einen neuen Requester gegen service_name an.

Erzeugt zwei Topics — <service>_Request (Writer) und <service>_Reply (Reader) — und einen Publisher/Subscriber- Paerchen. instance_name="" heisst “Default-Instance, kein PID_SERVICE_INSTANCE_NAME”.

§Errors
  • RpcError::InvalidServiceName falls der Name leer/illegal ist.
  • RpcError::Dcps bei Topic/Writer/Reader-Anlegen-Fehlern.
  • RpcError::DuplicateInstanceName falls auf demselben Participant bereits ein Requester/Replier mit gleichem (service, instance)-Paar laeuft.
Source

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

Wie Self::new, aber mit explizitem service_instance_name (Spec §7.8.2 PID 0x0080).

§Errors

Siehe Self::new.

Source

pub fn service_name(&self) -> &str

Service-Name, gegen den dieser Requester arbeitet.

Source

pub fn instance_name(&self) -> &str

Service-Instance-Name ("" falls Default-Instance).

Source

pub fn pending_count(&self) -> usize

Anzahl outstanding Requests.

Source

pub fn default_timeout(&self) -> Duration

Aktuelle Default-Timeout-Konfiguration.

Source

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

Schickt einen Request ohne auf Reply zu warten. Liefert einen mpsc::Receiver, ueber den der Caller spaeter mit mpsc::Receiver::recv (oder selbst-getriebener tick()-Schleife) den Reply abholt.

§Errors

RpcError::Dcps bei Encoder- oder Writer-Fehlern.

Source

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

Sendet einen Oneway-Request — kein Reply erwartet, kein pending-Slot.

§Errors

RpcError::Dcps bei Encoder- oder Writer-Fehlern.

Source

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

Sendet einen Request und blockiert bis Reply oder Timeout.

timeout=None nutzt RpcQos::request_timeout; explizit ueber Some(...) ueberschreiben.

§Errors
  • RpcError::Timeout wenn waehrend timeout kein Reply ankam.
  • RpcError::RemoteException(code) falls Server-Side eine RemoteExceptionCode != Ok zurueckgemeldet hat.
  • RpcError::Dcps bei Encode/Decode/Writer-Fehlern.
Source

pub fn tick(&self)

Liest neue Replies aus dem Reader, korreliert via related_request_id, und feuert die zugeordneten mpsc::Sender. Idempotent (kein 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> 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>

§

impl<TIn, TOut> !UnwindSafe 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.