roo_transport
API Documentation for roo_transport
Loading...
Searching...
No Matches
in_buffer.h
Go to the documentation of this file.
1#pragma once
2
3#include "roo_backport.h"
4#include "roo_backport/byte.h"
6#include "roo_logging.h"
7
8namespace roo_transport {
9namespace internal {
10
11class InBuffer {
12 public:
13 enum Type { kUnset, kData, kFin };
14 InBuffer() : type_(kUnset), size_(0) {}
15
16 void clear() {
17 type_ = kUnset;
18 size_ = 0;
19 }
20
21 void set(Type type, const roo::byte* payload, uint8_t size) {
22 CHECK_LE(size, 248);
23 memcpy(payload_, payload, size);
24 type_ = type;
25 size_ = size;
26 }
27
28 const roo::byte* data() const { return payload_; }
29 Type type() const { return type_; }
30 uint8_t size() const { return size_; }
31
32 private:
33 Type type_;
34 uint8_t size_;
35 roo::byte payload_[248];
36};
37
38} // namespace internal
39} // namespace roo_transport
const roo::byte * data() const
Definition in_buffer.h:28
void set(Type type, const roo::byte *payload, uint8_t size)
Definition in_buffer.h:21