Class: Rust::Types::StrSlice
- Inherits:
-
Type
- Object
- Type
- Rust::Types::StrSlice
show all
- Defined in:
- lib/rust_require/types/string.rb
Instance Attribute Summary
Attributes inherited from Type
#rust_type
Instance Method Summary
collapse
Methods inherited from Type
#c_input_type, #c_type, #ffi_input_type, #ffi_output_type, #initialize, rust_type
Instance Method Details
61
62
63
|
# File 'lib/rust_require/types/string.rb', line 61
def c_input_conversion(slice)
"#{slice}"
end
|
#c_output_conversion(name) ⇒ Object
57
58
59
|
# File 'lib/rust_require/types/string.rb', line 57
def c_output_conversion(name)
not_implemented
end
|
#c_output_type ⇒ Object
53
54
55
|
# File 'lib/rust_require/types/string.rb', line 53
def c_output_type
not_implemented
end
|
#ffi_type ⇒ Object
65
|
# File 'lib/rust_require/types/string.rb', line 65
def ffi_type; Rust::Slice.by_value; end
|
#not_implemented ⇒ Object
49
50
51
|
# File 'lib/rust_require/types/string.rb', line 49
def not_implemented
raise NotImplementedError, '&str as rust output parameter is not supported, use String instead!'
end
|
71
72
73
74
75
76
|
# File 'lib/rust_require/types/string.rb', line 71
def ruby_input_conversion(str)
str.encode!(Encoding::UTF_8)
len = str.bytesize
start = FFI::MemoryPointer.from_string(str).address
Rust::Slice.from(start, len)
end
|
#ruby_output_conversion(slice) ⇒ Object
67
68
69
|
# File 'lib/rust_require/types/string.rb', line 67
def ruby_output_conversion(slice)
not_implemented
end
|
#rust_type_regex ⇒ Object
45
46
47
|
# File 'lib/rust_require/types/string.rb', line 45
def rust_type_regex
/^&(mut)?( )?str$/
end
|