core_crypto_ffi

Module bindings

Source
Expand description

§CoreCrypto FFI Details

§Bindings

  • WASM / TypeScript bindings are self-documented in [crypto-ffi/bindings/js/CoreCrypto.ts].
    • Please refer to your IDE of choice’s inlay hints or simply check out the TypeDoc-generated documentation on typescript
    • Naming convention wise, snake_case gets translated to the TS idiomatic camelCase for methods and PascalCase for classes/interfaces
  • UniFFI-generated bindings (Swift, Kotlin) share the same characteristics in terms of naming convention translation.
    • The general convention is that the idiomatic Rust snake_case gets translated to the language’s idiomatic convention. Fortunately, for both Swift and Kotlin, the convention is camelCase for methods and PascalCase for classes/interfaces.

§Naming conventions table

ItemRustSwiftKotlinTypeScript
Methods/Functionssnake_casecamelCasecamelCasecamelCase
Variables/Argumentssnake_casecamelCasecamelCasecamelCase
Classes/InterfacesPascalCasePascalCasePascalCasePascalCase

§Types equivalence table

RustSwiftKotlinTypeScript
boolBoolBooleanboolean
u8UInt8UBytenumber
u16UInt16UShortnumber
u32UInt32UIntnumber
u64UInt64ULongnumber
i8Int8Bytenumber
i16Int16Shortnumber
i32Int32Intnumber
i64Int64Longnumber
f32FloatFloatnumber
f64DoubleDoublenumber
String / &strStringStringstring
std::time::SystemTimeDatejava.time.InstantDate
std::time::DurationTimeIntervaljava.time.Durationnumber (in milliseconds)
Option<T>Optional<T>Optional<T>T?
Vec<T>Array<T>List<T>Array<T>
HashMap<String, T>Dictionary<String, T>Map<String, T>Record<string, T>
()nilnullnull
Result<T, E>func placeholder() throws E -> TT placeholder() throws Efunction placeholder(): T // @throws E

§Adding new APIs

  1. Make your changes wherever applicable.
  2. Make sure your new API is available on MlsCentral, while respecting encapsulation
    • For example, adding MlsConversation::hello() would mean exposing a new MlsCentral::conversation_hello(conversation_id: ConversationId)
  3. Expose your new API on both crypto-ffi/src/[generic|wasm].rs.
  4. Add the new APIs respecting the appropriate calling conventions defined above to
    • Kotlin/Android: crypto-ffi/bindings/jvm/src/main/kotlin/com/wire/crypto/client/[CoreCryptoCentral|E2eiClient|MLSClient].kt
    • TypeScript/Web: crypto-ffi/bindings/js/CoreCrypto.ts (Swift/iOS are automatically generated)
  5. Add documentation for the new API in the bindings.
  6. Add a test for the bindings. This is easily done by extending the existing test suite in crypto-ffi/bindings/js/test/CoreCrypto.test.ts. For example, see this commit.

Modules§