Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. C/C++
  4. Comms
  5. pw_rpc
  6. pw_protobuf RPC
  7. pw::rpc::PwpbServerReader< Request, Response > Class Template Reference
pw::rpc::PwpbServerReader< Request, Response > Class Template Reference

Overview

template<typename Request, typename Response>
class pw::rpc::PwpbServerReader< Request, Response >

Receives pw_protobuf requests and sends the final pw_protobuf response for a client streaming RPC on a server.

Template Parameters
RequestThe generated pw_protobuf request message struct type.
ResponseThe generated pw_protobuf response message struct type.
Inheritance diagram for pw::rpc::PwpbServerReader< Request, Response >:
pw::rpc::internal::BasePwpbServerReader< Request >

Public Member Functions

constexpr PwpbServerReader ()=default
 Creates an inactive PwpbServerReader into which an active call can be moved.
 
 PwpbServerReader (PwpbServerReader &&)=default
 
PwpbServerReader & operator= (PwpbServerReader &&)=default
 
Status Finish (const Response &response, Status status=OkStatus())
 Closes the RPC and sends the final Response message and status.
 
Status TryFinish (const Response &response, Status status=OkStatus())
 Attempts to close the RPC and send the final Response message and status to the client.
 

Static Public Member Functions

template<auto kMethod, typename ServiceImpl >
static PwpbServerReader Open (Server &server, uint32_t channel_id, ServiceImpl &service)
 Creates a PwpbServerReader that is ready to send a response to a particular RPC.
 

Friends

class internal::Call
 
class internal::PwpbMethod
 
class Server
 
template<typename , typename , uint32_t >
class internal::test::InvocationContext
 

Member Function Documentation

◆ Finish()

template<typename Request , typename Response >
Status pw::rpc::PwpbServerReader< Request, Response >::Finish ( const Response &  response,
Status  status = OkStatus() 
)
inline

Closes the RPC and sends the final Response message and status.

Parameters
[in]responseThe Response message struct to encode and send.
[in]statusThe overall status of the RPC to send to the client.
Returns
  • OK: The response was successfully sent.
  • FAILED_PRECONDITION: The responder is closed.
  • INTERNAL: pw_rpc was unable to encode the pw_protobuf message.
  • Other error codes from the ChannelOutput implementation if sending the packet failed.

◆ Open()

template<typename Request , typename Response >
template<auto kMethod, typename ServiceImpl >
static PwpbServerReader pw::rpc::PwpbServerReader< Request, Response >::Open ( Server &  server,
uint32_t  channel_id,
ServiceImpl &  service 
)
inlinestatic

Creates a PwpbServerReader that is ready to send a response to a particular RPC.

This can be used for testing or to finish an RPC that has not been started by a client.

Template Parameters
kMethodPointer to the generated service method.
ServiceImplThe service implementation class.
Parameters
[in,out]serverThe RPC Server on which to open the call.
[in]channel_idThe ID of the channel on which to send the response.
[in,out]serviceThe registered service instance handling the RPC.
Returns
An active PwpbServerReader bound to the specified channel and method.

◆ TryFinish()

template<typename Request , typename Response >
Status pw::rpc::PwpbServerReader< Request, Response >::TryFinish ( const Response &  response,
Status  status = OkStatus() 
)
inline

Attempts to close the RPC and send the final Response message and status to the client.

Unlike Finish(), the call remains open if sending the packet fails, allowing the caller to retry.

Parameters
[in]responseThe Response message struct to encode and send.
[in]statusThe overall status of the RPC to send to the client.
Returns
  • OK: The response was successfully sent and the call was closed.
  • FAILED_PRECONDITION: The responder is closed.
  • INTERNAL: pw_rpc was unable to encode the pw_protobuf message.
  • Other error codes from the ChannelOutput implementation if sending the packet failed (the call remains active).

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