roo_transport
API Documentation for roo_transport
Loading...
Searching...
No Matches
header.h
Go to the documentation of this file.
1#pragma once
2
3#include <stdint.h>
4
5#include "roo_backport.h"
6#include "roo_backport/byte.h"
9
10namespace roo_transport {
11
12class RpcHeader {
13 public:
14 enum MessageType { kUnset = -1, kRequest = 0, kResponse = 1 };
15
16 static constexpr size_t kMaxSerializedSize = 32;
17
19 : type_(kUnset),
20 first_message_(false),
21 last_message_(false),
22 has_timeout_(false),
23 stream_id_(0) {}
24
27
30
32
33 size_t serialize(roo::byte* buffer, size_t buffer_size) const;
34 size_t deserialize(const roo::byte* buffer, size_t buffer_size);
35
36 MessageType type() const { return type_; }
37 bool isFirstMessage() const { return first_message_; }
38 bool isLastMessage() const { return last_message_; }
39 bool hasTimeout() const { return has_timeout_; }
40 RpcStreamId streamId() const { return stream_id_; }
41
43 uint32_t timeoutMs() const;
44
46
47 private:
48 MessageType type_;
49 bool first_message_;
50 bool last_message_;
51 bool has_timeout_;
52 RpcStreamId stream_id_;
53
54 union {
55 struct {
59 struct {
62 struct {
63 // No additional fields.
65 };
66};
67
68} // namespace roo_transport
static RpcHeader NewUnaryResponse(RpcStreamId stream_id, RpcStatus status)
Definition header.cpp:52
struct roo_transport::RpcHeader::@0::@3 last_response_
uint32_t timeoutMs() const
Definition header.cpp:15
size_t serialize(roo::byte *buffer, size_t buffer_size) const
Definition header.cpp:63
struct roo_transport::RpcHeader::@0::@4 continuation_
size_t deserialize(const roo::byte *buffer, size_t buffer_size)
Definition header.cpp:84
bool hasTimeout() const
Definition header.h:39
struct roo_transport::RpcHeader::@0::@2 new_request_
static constexpr size_t kMaxSerializedSize
Definition header.h:16
bool isLastMessage() const
Definition header.h:38
RpcStatus responseStatus() const
Definition header.cpp:20
RpcFunctionId function_id_
Definition header.h:56
RpcFunctionId functionId() const
Definition header.cpp:10
static RpcHeader NewUnaryRequest(RpcFunctionId function_id, RpcStreamId stream_id)
Definition header.cpp:25
MessageType type() const
Definition header.h:36
bool isFirstMessage() const
Definition header.h:37
RpcStreamId streamId() const
Definition header.h:40
uint32_t RpcFunctionId
Definition rpc.h:10
uint32_t RpcStreamId
Definition rpc.h:11