You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 27, 2023. It is now read-only.
Thin wrappers can be problematic to write by hand and maintain as APIs change.
148
-
It is desirable to have thin wrappers generated programmatically.
148
+
Bindings can be problematic to write by hand and maintain as APIs change.
149
+
It is desirable to have bindings generated programmatically.
149
150
Rust supports generating FFI using `bindgen`. `bindgen` can map to other languages like
150
-
C and WASM. Thus thin wrappers should be created and maintained as much as possible using features like `bindgen`.
151
-
Thin wrappers should be included in the Ursa project itself in a folder called `wrappers`. This will allow them to
152
-
stay in-sync with any other changes to the core library.
151
+
C and WASM. Thus bindings should be created and maintained as much as possible using features like `bindgen`.
152
+
Bindings should be included in the Ursa project itself in a folder called `wrappers`. This will allow them to
153
+
stay in-sync with any other changes to the core library. Rust also offers the [ffi-support](https://crates.io/crates/ffi-support) crate. The crate exposes
154
+
Rust objects in three ways:
155
+
156
+
- Serialization methods like proto or flat buffers or JSON.
157
+
- HandleMaps that return handle Id's to callers
158
+
- Converts between raw Rust native types to C native types.
159
+
160
+
Bindings should use the best appropriate option for the given language. For example, WASM must use serialization but Python could use any of them.
153
161
154
162
Idiomatic wrappers usually cannot be generated by hand as they require more in depth language experience
155
163
than automatic generators can produce. Therefore, idiomatic wrappers should be written by project contributors
@@ -160,9 +168,9 @@ Here are general guidelines for producing wrappers:
160
168
161
169
`<language>` should follow the naming convention as described [here](https://support.codebasehq.com/articles/tips-tricks/syntax-highlighting-in-markdown)
162
170
163
-
-Thin wrappers
171
+
-Bindings
164
172
- Produced by code
165
-
- Output into the `libursa/wrappers/<language>/folder`
173
+
- Output into the `libursa/bindings/<language>/folder`
166
174
- Idiomatic wrappers
167
175
- Written by developers
168
176
- Implemented as best deemed by contributors/community
@@ -180,7 +188,7 @@ Here are general guidelines for producing wrappers:
180
188
[drawbacks]: #drawbacks
181
189
182
190
- Some developers may want all ursa code written in the language of their needs to avoid issues presented by FFI.
183
-
- Some languages cannot generate thin wrappers yet using `bindgen`.
191
+
- Some languages cannot generate bindings yet using `bindgen`.
0 commit comments