Class: Rust::Types::Type
- Inherits:
-
Object
- Object
- Rust::Types::Type
- Defined in:
- lib/rust_require/types.rb
Overview
The base class for Types with simple defaults
Instance Attribute Summary collapse
-
#rust_type ⇒ Object
name of the rust type (String) raises error when @rust_type is nil.
Class Method Summary collapse
-
.rust_type ⇒ Object
accessor for @rust_type of Type class.
Instance Method Summary collapse
-
#c_input_conversion(name) ⇒ Object
rust code performing necessary conversions on input from ruby with name before passing it to original rust fn (String).
-
#c_input_type ⇒ Object
name of the type passed in from ruby (String).
-
#c_output_conversion(name) ⇒ Object
rust code performing necessary conversions on output with name from rust fn before returning it to ruby (String).
-
#c_output_type ⇒ Object
name of the type returned by the wrapper fn to ruby.
- #c_type ⇒ Object
-
#ffi_input_type ⇒ Object
returns symbol understood by ruby ffi gem corresponding to @rust_type as input.
-
#ffi_output_type ⇒ Object
returns symbol understood by ruby ffi gem corresponding to @rust_type as output.
-
#ffi_type ⇒ Object
shortcut for ffi type (input and output).
-
#initialize ⇒ Type
constructor
set @rust_type from class variable @rust_type.
-
#ruby_input_conversion(obj) ⇒ Object
return value will directly be passed into the ffi fn.
-
#ruby_output_conversion(obj) ⇒ Object
obj is return value of ffi fn return value will be the final result of ffi call.
- #rust_type_regex ⇒ Object
Constructor Details
#initialize ⇒ Type
set @rust_type from class variable @rust_type
45 46 47 |
# File 'lib/rust_require/types.rb', line 45 def initialize @rust_type = self.class.rust_type end |
Instance Attribute Details
#rust_type ⇒ Object
name of the rust type (String) raises error when @rust_type is nil
51 52 53 54 |
# File 'lib/rust_require/types.rb', line 51 def rust_type raise NotImplementedError, "This is a bug." if @rust_type.nil? @rust_type end |
Class Method Details
.rust_type ⇒ Object
accessor for @rust_type of Type class
42 |
# File 'lib/rust_require/types.rb', line 42 def self.rust_type; @rust_type; end |
Instance Method Details
#c_input_conversion(name) ⇒ Object
rust code performing necessary conversions on input from ruby with name before passing it to original rust fn (String)
72 |
# File 'lib/rust_require/types.rb', line 72 def c_input_conversion(name); name; end |
#c_input_type ⇒ Object
name of the type passed in from ruby (String)
65 |
# File 'lib/rust_require/types.rb', line 65 def c_input_type; c_type; end |
#c_output_conversion(name) ⇒ Object
rust code performing necessary conversions on output with name from rust fn before returning it to ruby (String)
76 |
# File 'lib/rust_require/types.rb', line 76 def c_output_conversion(name); name; end |
#c_output_type ⇒ Object
name of the type returned by the wrapper fn to ruby
68 |
# File 'lib/rust_require/types.rb', line 68 def c_output_type; c_type; end |
#c_type ⇒ Object
62 |
# File 'lib/rust_require/types.rb', line 62 def c_type; rust_type; end |
#ffi_input_type ⇒ Object
returns symbol understood by ruby ffi gem corresponding to @rust_type as input
85 |
# File 'lib/rust_require/types.rb', line 85 def ffi_input_type; ffi_type; end |
#ffi_output_type ⇒ Object
returns symbol understood by ruby ffi gem corresponding to @rust_type as output
88 |
# File 'lib/rust_require/types.rb', line 88 def ffi_output_type; ffi_type; end |
#ffi_type ⇒ Object
shortcut for ffi type (input and output)
82 |
# File 'lib/rust_require/types.rb', line 82 def ffi_type; rust_type.to_sym; end |
#ruby_input_conversion(obj) ⇒ Object
return value will directly be passed into the ffi fn
91 |
# File 'lib/rust_require/types.rb', line 91 def ruby_input_conversion(obj); obj; end |
#ruby_output_conversion(obj) ⇒ Object
obj is return value of ffi fn return value will be the final result of ffi call
95 |
# File 'lib/rust_require/types.rb', line 95 def ruby_output_conversion(obj); obj; end |
#rust_type_regex ⇒ Object
58 59 60 |
# File 'lib/rust_require/types.rb', line 58 def rust_type_regex Regexp.new @rust_type end |