Class: Google::Protobuf::MethodDescriptor

Inherits:
Object
  • Object
show all
Extended by:
FFI::DataConverter, Internal::PointerHelper, Internal::TypeSafety
Includes:
Internal::Convert
Defined in:
lib/google/protobuf/ffi/method_descriptor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Internal::PointerHelper

descriptor_from_file_def

Methods included from Internal::TypeSafety

to_native

Methods included from Internal::Convert

#convert_ruby_to_upb, #convert_upb_to_ruby, #map_create_hash, #message_value_deep_copy, #repeated_field_create_array, #scalar_create_hash, #to_h_internal

Instance Attribute Details

#method_defObject (readonly)

Returns the value of attribute method_def.



11
12
13
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 11

def method_def
  @method_def
end

Class Method Details

.from_native(method_def, _ = nil) ⇒ Object

Parameters:

  • service_def (::FFI::Pointer)

    MethodDef pointer to be wrapped

  • _ (Object) (defaults to: nil)

    Unused



35
36
37
38
39
40
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 35

def from_native(method_def, _ = nil)
  return nil if method_def.nil? or method_def.null?
  service_def = Google::Protobuf::FFI.raw_service_def_by_raw_method_def(method_def)
  file_def = Google::Protobuf::FFI.file_def_by_raw_service_def(service_def)
  descriptor_from_file_def(file_def, method_def)
end

.new(*arguments, &block) ⇒ Object



43
44
45
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 43

def self.new(*arguments, &block)
  raise "Descriptor objects may not be created from Ruby."
end

.to_native(value, _) ⇒ Object

Parameters:

  • value (MethodDescriptor)

    MethodDescriptor to convert to an FFI native type

  • _ (Object)

    Unused



25
26
27
28
29
30
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 25

def to_native(value, _)
  method_def_ptr = value.nil? ? nil : value.instance_variable_get(:@method_def)
  return ::FFI::Pointer::NULL if method_def_ptr.nil?
  raise "Underlying method_def was null!" if method_def_ptr.null?
  method_def_ptr
end

Instance Method Details

#client_streamingObject



76
77
78
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 76

def client_streaming
  @client_streaming ||= Google::Protobuf::FFI.method_client_streaming(self)
end

#input_typeObject



68
69
70
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 68

def input_type
  @input_type ||= Google::Protobuf::FFI.method_input_type(self)
end

#inspectObject



51
52
53
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 51

def inspect
  "#{self.class.name}: #{name}"
end

#nameObject



55
56
57
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 55

def name
  @name ||= Google::Protobuf::FFI.get_method_name(self)
end

#optionsObject



59
60
61
62
63
64
65
66
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 59

def options
  @options ||= begin
    size_ptr = ::FFI::MemoryPointer.new(:size_t, 1)
    temporary_arena = Google::Protobuf::FFI.create_arena
    buffer = Google::Protobuf::FFI.method_options(self, size_ptr, temporary_arena)
    Google::Protobuf::MethodOptions.decode(buffer.read_string_length(size_ptr.read(:size_t)).force_encoding("ASCII-8BIT").freeze).freeze
  end
end

#output_typeObject



72
73
74
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 72

def output_type
  @output_type ||= Google::Protobuf::FFI.method_output_type(self)
end

#server_streamingObject



80
81
82
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 80

def server_streaming
  @server_streaming ||= Google::Protobuf::FFI.method_server_streaming(self)
end

#to_sObject



47
48
49
# File 'lib/google/protobuf/ffi/method_descriptor.rb', line 47

def to_s
  inspect
end