grpc_frame library
gRPC Length-Prefixed-Message framing.
Implements the gRPC wire format for HTTP/2 DATA frames as specified in grpc/doc/PROTOCOL-HTTP2.md.
Frame layout:
Byte 0: Compressed-Flag (0 = uncompressed, 1 = compressed)
Bytes 1-4: Message-Length (4 bytes, big-endian unsigned int32)
Bytes 5+: Message data (protobuf binary)
Constants
- grpcFlagCompressed → const int
- Flag-byte bit 0: the payload is compressed.
- grpcFlagEndOfStream → const int
- Flag-byte bit 1: this is the Connect streaming end-of-stream envelope.
Functions
-
extractServiceMethods(
Map< String, Object?> serviceDescriptor) → List<Map< String, Object?> > - Extract service method descriptors from a FileDescriptorProto-like map.
-
grpcDecodeFrame(
List< int> buffer, int offset) → Map<String, Object?> -
Decode a single gRPC frame from
bufferstarting atoffset. -
grpcDecodeFrames(
List< int> buffer) → List<Map< String, Object?> > -
Decode all gRPC frames from
buffer. -
grpcDecodeFrameWithFlags(
List< int> buffer, int offset) → Map<String, Object?> -
Decode a single frame from
bufferatoffset, exposing the full flag byte. -
grpcEncodeFrame(
List< int> messageBytes, {bool compressed = false}) → List<int> - Encode a gRPC frame: 1-byte compression flag + 4-byte big-endian length + message bytes.
-
grpcEncodeFrames(
List< List< messages, {bool compressed = false}) → List<int> >int> - Encode multiple gRPC frames (for streaming).
-
grpcEncodeFrameWithFlags(
List< int> messageBytes, int flags) → List<int> -
Encode a frame with an explicit
flagsbyte (1 flag + 4-byte big-endian length + message bytes). -
grpcFlagIsCompressed(
int flags) → bool -
Whether the compression bit (bit 0) is set in
flags. -
grpcFlagIsEndOfStream(
int flags) → bool -
Whether the end-of-stream bit (bit 1) is set in
flags(Connect streaming). -
grpcMakeFlags(
{bool compressed = false, bool endOfStream = false}) → int -
Builds a flag byte from the
compressed/endOfStreambits.