Pigweed
C/C++ API Reference
Home
Modules
Loading...
Searching...
No Matches
writer.h
1
// Copyright 2021 The Pigweed Authors
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4
// use this file except in compliance with the License. You may obtain a copy of
5
// the License at
6
//
7
// https://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12
// License for the specific language governing permissions and limitations under
13
// the License.
14
#pragma once
15
16
#include <cstdint>
17
18
#include "pw_bytes/span.h"
19
#include "pw_function/function.h"
20
#include "pw_rpc/internal/lock.h"
21
#include "pw_status/status.h"
22
#include "pw_status/status_with_size.h"
23
24
namespace
pw::rpc {
25
namespace
internal {
26
class
Call;
27
}
28
30
31
// The Writer class allows writing requests or responses to a streaming RPC.
32
// ClientWriter, ClientReaderWriter, ServerWriter, and ServerReaderWriter
33
// classes can be used as a generic Writer.
34
class
Writer
{
35
public
:
36
Writer
(
const
Writer
&) =
delete
;
37
Writer
(
Writer
&&) =
delete
;
38
39
Writer
& operator=(
const
Writer
&) =
delete
;
40
Writer
& operator=(
Writer
&&) =
delete
;
41
42
bool
active()
const
;
43
uint32_t channel_id()
const
;
44
45
Status
Write(
ConstByteSpan
payload)
PW_LOCKS_EXCLUDED
(internal::rpc_lock());
46
Status
Write(
const
Function
<
StatusWithSize
(
ByteSpan
)>& callback)
47
PW_LOCKS_EXCLUDED
(internal::rpc_lock());
48
49
private
:
50
// Only allow Call to inherit from Writer. This guarantees that Writers can
51
// always safely downcast to Call.
52
friend
class
internal::Call;
53
54
// Writers cannot be created directly. They may only be used as a reference to
55
// an existing call object.
56
constexpr
Writer
() =
default
;
57
};
58
60
61
}
// namespace pw::rpc
pw::Status
Definition:
status.h:109
pw::StatusWithSize
Definition:
status_with_size.h:51
pw::rpc::Writer
Definition:
writer.h:34
pw::span< const std::byte >
pw::Function
fit::function_impl< function_internal::config::kInlineCallableSize, !function_internal::config::kEnableDynamicAllocation, FunctionType, PW_FUNCTION_DEFAULT_ALLOCATOR_TYPE > Function
Definition:
function.h:73
PW_LOCKS_EXCLUDED
#define PW_LOCKS_EXCLUDED(...)
Definition:
lock_annotations.h:176
pw_rpc
public
pw_rpc
writer.h
Generated by
1.9.6