proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
MessageToByteEncoder.h
Go to the documentation of this file.
1
/*
2
* Copyright 2017-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <
wangle/channel/Handler.h
>
20
21
namespace
wangle
{
22
27
template
<
typename
M>
28
class
MessageToByteEncoder
:
public
OutboundHandler
<M, std::unique_ptr<folly::IOBuf>> {
29
public
:
30
typedef
typename
OutboundHandler<M, std::unique_ptr<folly::IOBuf>
>
::Context
Context
;
31
32
virtual
std::unique_ptr<folly::IOBuf>
encode
(
M
& msg) = 0;
33
34
folly::Future<folly::Unit>
write
(Context* ctx,
M
msg)
override
{
35
auto
buf =
encode
(msg);
36
return
buf ? ctx->
fireWrite
(
std::move
(buf)) :
folly::makeFuture
();
37
}
38
};
39
40
}
// namespace wangle
wangle::MessageToByteEncoder::Context
OutboundHandler< M, std::unique_ptr< folly::IOBuf > >::Context Context
Definition:
MessageToByteEncoder.h:30
wangle::OutboundHandlerContext::fireWrite
virtual folly::Future< folly::Unit > fireWrite(Out msg)=0
folly::gen::move
constexpr detail::Map< Move > move
Definition:
Base-inl.h:2567
wangle::MessageToByteEncoder::write
folly::Future< folly::Unit > write(Context *ctx, M msg) override
Definition:
MessageToByteEncoder.h:34
wangle
Definition:
Acceptor.cpp:49
wangle::OutboundHandlerContext< std::unique_ptr< folly::IOBuf > >
wangle::OutboundHandler
Definition:
Handler.h:137
wangle::MessageToByteEncoder::encode
virtual std::unique_ptr< folly::IOBuf > encode(M &msg)=0
folly::Future
Definition:
FiberManagerInternal.h:46
M
**Optimized Holders **The template hazptr_array< M > provides most of the functionality *of M hazptr_holder s but with faster construction destruction *for M
Definition:
Hazptr.h:104
Handler.h
wangle::MessageToByteEncoder
Definition:
MessageToByteEncoder.h:28
folly::makeFuture
Future< typename std::decay< T >::type > makeFuture(T &&t)
Definition:
Future-inl.h:1310
proxygen
wangle
wangle
codec
MessageToByteEncoder.h
Generated by
1.8.11