Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_rpc
  6. pw::rpc::Rpc2ServiceAdapter Class Reference
pw::rpc::Rpc2ServiceAdapter Class Reference

Overview

Wraps a pw_rpc service as a pw::rpc2::Service.

pw_rpc2 calls are forwarded to the adapter's pw::rpc::Server, which dispatches them to whichever service with this service's ID is registered there. The wrapper does not register or reference service. To construct, own, and register the service in one object, use Rpc2ServiceFor.

If no service with this ID is registered with the adapter's server, calls fail with pw::rpc2::RpcStatus::Unimplemented().

Inheritance diagram for pw::rpc::Rpc2ServiceAdapter:
pw::rpc2::Service pw::IntrusiveForwardList< T >::Item pw::rpc::Rpc2ServiceFor< LegacyService >

Public Member Functions

template<typename LegacyService >
 Rpc2ServiceAdapter (Rpc2ServerAdapter &adapter, LegacyService &service)
 
template<auto... kNonOkResponseMethods, typename LegacyService >
 Rpc2ServiceAdapter (Rpc2ServerAdapter &adapter, internal::DeliverNonOkResponsesTag< kNonOkResponseMethods... > policy, LegacyService &service)
 
 Rpc2ServiceAdapter (const Rpc2ServiceAdapter &)=delete
 
Rpc2ServiceAdapter & operator= (const Rpc2ServiceAdapter &)=delete
 

Protected Member Functions

Rpc2ServerAdapter & adapter () const
 
- Protected Member Functions inherited from pw::rpc2::Service
constexpr Service (uint32_t service_id, span< const internal::Method > methods)
 
 ~Service ()
 
- Protected Member Functions inherited from pw::IntrusiveForwardList< T >::Item
constexpr Item ()=default
 

Friends

class internal::Rpc2LegacyCall
 

Constructor & Destructor Documentation

◆ Rpc2ServiceAdapter() [1/2]

template<typename LegacyService >
pw::rpc::Rpc2ServiceAdapter::Rpc2ServiceAdapter ( Rpc2ServerAdapter &  adapter,
LegacyService &  service 
)
inline

Wraps service for registration with a pw::rpc2::Server.

Parameters
[in]adapterThe adapter that runs service's handlers. Must outlive this object.
[in]serviceThe pw_rpc service implementation to serve. Register it with the adapter's pw::rpc::Server.

◆ Rpc2ServiceAdapter() [2/2]

template<auto... kNonOkResponseMethods, typename LegacyService >
pw::rpc::Rpc2ServiceAdapter::Rpc2ServiceAdapter ( Rpc2ServerAdapter &  adapter,
internal::DeliverNonOkResponsesTag< kNonOkResponseMethods... >  policy,
LegacyService &  service 
)
inline

Wraps service for registration with a pw::rpc2::Server, delivering the response payload (with kOk) for selected unary or client streaming methods even when their pw_rpc handler finishes with a non-OK status.

See DeliverNonOkResponses() for usage and caveats regarding early error returns.

Parameters
[in]adapterThe adapter that runs service's handlers. Must outlive this object.
[in]policyDeliverNonOkResponses<Methods...>() for specific methods, or DeliverNonOkResponses() for all unary and client streaming methods of service.
[in]serviceThe pw_rpc service implementation to serve. Register it with the adapter's pw::rpc::Server.

The documentation for this class was generated from the following file: