proxygen
|
#include <LengthFieldPrepender.h>
Public Member Functions | |
LengthFieldPrepender (int lengthFieldLength=4, int lengthAdjustment=0, bool lengthIncludesLengthField=false, bool networkByteOrder=true) | |
folly::Future< folly::Unit > | write (Context *ctx, std::unique_ptr< folly::IOBuf > buf) override |
Public Member Functions inherited from wangle::OutboundHandler< Win, Wout > | |
~OutboundHandler () override=default | |
virtual folly::Future< folly::Unit > | write (Context *ctx, Win msg)=0 |
virtual folly::Future< folly::Unit > | writeException (Context *ctx, folly::exception_wrapper e) |
virtual folly::Future< folly::Unit > | close (Context *ctx) |
Public Member Functions inherited from wangle::HandlerBase< OutboundHandlerContext< Wout > > | |
virtual | ~HandlerBase ()=default |
virtual void | attachPipeline (OutboundHandlerContext< Wout > *) |
virtual void | detachPipeline (OutboundHandlerContext< Wout > *) |
OutboundHandlerContext< Wout > * | getContext () |
Private Attributes | |
int | lengthFieldLength_ |
int | lengthAdjustment_ |
bool | lengthIncludesLengthField_ |
bool | networkByteOrder_ |
Additional Inherited Members | |
Public Types inherited from wangle::OutboundHandler< Win, Wout > | |
typedef folly::Unit | rin |
typedef folly::Unit | rout |
typedef Win | win |
typedef Wout | wout |
typedef OutboundHandlerContext< Wout > | Context |
Static Public Attributes inherited from wangle::OutboundHandler< Win, Wout > | |
static const HandlerDir | dir = HandlerDir::OUT |
An encoder that prepends the length of the message. The length value is prepended as a binary form.
For example, LengthFieldPrepender(2)will encode the following 12-bytes string:
+-------------—+ | "HELLO, WORLD" | +-------------—+
into the following:
+-----—+-------------—+
If you turned on the lengthIncludesLengthFieldLength flag in the constructor, the encoded data would look like the following (12 (original data) + 2 (prepended data) = 14 (0xE)):
+-----—+-------------—+
Definition at line 50 of file LengthFieldPrepender.h.
|
explicit |
Definition at line 25 of file LengthFieldPrepender.cpp.
|
override |
Definition at line 40 of file LengthFieldPrepender.cpp.
References c, folly::IOBuf::computeChainDataLength(), folly::IOBuf::create(), wangle::OutboundHandlerContext< Out >::fireWrite(), lengthAdjustment_, lengthFieldLength_, lengthIncludesLengthField_, folly::gen::move, networkByteOrder_, uint16_t, uint32_t, uint64_t, and uint8_t.
|
private |
Definition at line 63 of file LengthFieldPrepender.h.
Referenced by write().
|
private |
Definition at line 62 of file LengthFieldPrepender.h.
Referenced by write().
|
private |
Definition at line 64 of file LengthFieldPrepender.h.
Referenced by write().
|
private |
Definition at line 65 of file LengthFieldPrepender.h.
Referenced by write().