GRPC Core  18.0.0
Functions
byte_buffer_reader.cc File Reference
#include <grpc/support/port_platform.h>
#include <grpc/byte_buffer_reader.h>
#include <string.h>
#include <grpc/byte_buffer.h>
#include <grpc/grpc.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "src/core/lib/iomgr/exec_ctx.h"
#include "src/core/lib/slice/slice_internal.h"

Functions

int grpc_byte_buffer_reader_init (grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer)
 Initialize reader to read over buffer. More...
 
void grpc_byte_buffer_reader_destroy (grpc_byte_buffer_reader *reader)
 Cleanup and destroy reader. More...
 
int grpc_byte_buffer_reader_peek (grpc_byte_buffer_reader *reader, grpc_slice **slice)
 EXPERIMENTAL API - This function may be removed and changed, in the future. More...
 
int grpc_byte_buffer_reader_next (grpc_byte_buffer_reader *reader, grpc_slice *slice)
 Updates slice with the next piece of data from from reader and returns. More...
 
grpc_slice grpc_byte_buffer_reader_readall (grpc_byte_buffer_reader *reader)
 Merge all data from reader into single slice. More...
 

Function Documentation

◆ grpc_byte_buffer_reader_destroy()

void grpc_byte_buffer_reader_destroy ( grpc_byte_buffer_reader reader)

Cleanup and destroy reader.

◆ grpc_byte_buffer_reader_init()

int grpc_byte_buffer_reader_init ( grpc_byte_buffer_reader reader,
grpc_byte_buffer buffer 
)

Initialize reader to read over buffer.

Returns 1 upon success, 0 otherwise.

◆ grpc_byte_buffer_reader_next()

int grpc_byte_buffer_reader_next ( grpc_byte_buffer_reader reader,
grpc_slice slice 
)

Updates slice with the next piece of data from from reader and returns.

  1. Returns 0 at the end of the stream. Caller is responsible for calling grpc_slice_unref on the result.

◆ grpc_byte_buffer_reader_peek()

int grpc_byte_buffer_reader_peek ( grpc_byte_buffer_reader reader,
grpc_slice **  slice 
)

EXPERIMENTAL API - This function may be removed and changed, in the future.

Updates slice with the next piece of data from from reader and returns

  1. Returns 0 at the end of the stream. Caller is responsible for making sure the slice pointer remains valid when accessed.

NOTE: Do not use this function unless the caller can guarantee that the underlying grpc_byte_buffer outlasts the use of the slice. This is only safe when the underlying grpc_byte_buffer remains immutable while slice is being accessed.

◆ grpc_byte_buffer_reader_readall()

grpc_slice grpc_byte_buffer_reader_readall ( grpc_byte_buffer_reader reader)

Merge all data from reader into single slice.