aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby/ext/grpc/rb_byte_buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ruby/ext/grpc/rb_byte_buffer.c')
-rw-r--r--src/ruby/ext/grpc/rb_byte_buffer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c
index 47fd6d9120..65fa2f2cf6 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.c
+++ b/src/ruby/ext/grpc/rb_byte_buffer.c
@@ -68,3 +68,10 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
grpc_byte_buffer_reader_destroy(&reader);
return rb_string;
}
+
+VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice) {
+ if (GRPC_SLICE_START_PTR(slice) == NULL) {
+ rb_raise(rb_eRuntimeError, "attempt to convert uninitialized grpc_slice to ruby string");
+ }
+ return rb_str_new((char*)GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice));
+}