[][src]Module xaynet_mobile::ffi

Structs

ByteBuffer

ByteBuffer is a struct that represents an array of bytes to be sent over the FFI boundaries. There are several cases when you might want to use this, but the primary one for us is for returning protobuf-encoded data to Swift and Java. The type is currently rather limited (implementing almost no functionality), however in the future it may be more expanded.

FfiStr

FfiStr<'a> is a safe (#[repr(transparent)]) wrapper around a nul-terminated *const c_char (e.g. a C string). Conceptually, it is similar to std::ffi::CStr, except that it may be used in the signatures of extern "C" functions.

KeyPair

A signing key pair

LocalModelConfig

The model configuration of the model that is expected in xaynet_ffi_participant_set_model().

Enums

ModelDataType

The original primitive data type of the numerical values to be masked.

Constants

ERR_CRYPTO_INIT

Failed to initialized the crypto library

ERR_CRYPTO_PUBLIC_KEY

Invalid public signing key

ERR_CRYPTO_SECRET_KEY

Invalid secret signing key

ERR_GLOBALMODEL_CONVERT

Failed to get the global model: invalid model

ERR_GLOBALMODEL_DATATYPE

Failed to get the global model: invalid data type

ERR_GLOBALMODEL_IO

Failed to get the global model: communication with the coordinator failed

ERR_GLOBALMODEL_LEN

Failed to get the global model: invalid buffer length

ERR_INVALID_URL

Invalid coordinator URL

ERR_NULLPTR

NULL pointer argument

ERR_SETMODEL_DATATYPE

Failed to set the local model: invalid data type

ERR_SETMODEL_MODEL

Failed to set the local model: invalid model

ERR_SETTINGS_KEYS

Invalid settings: signing keys are not set

ERR_SETTINGS_URL

Invalid settings: coordinator URL is not set

GLOBALMODEL_NONE

No global model is currently available

OK

Return value upon success

PARTICIPANT_MADE_PROGRESS

The participant is expected to set the model it trained

PARTICIPANT_NEW_GLOBALMODEL

A new global model is available

PARTICIPANT_SHOULD_SET_MODEL

The participant is expected to set the model it trained

PARTICIPANT_TASK_NONE

The participant is not taking part in the sum or update task

PARTICIPANT_TASK_SUM

The participant is not taking part in the sum task

PARTICIPANT_TASK_UPDATE

The participant is not taking part in the update task

Functions

xaynet_ffi_byte_buffer_destroy

Destroy the given ByteBuffer and free its memory. This function must only be called on ByteBuffers that have been created on the Rust side of the FFI. If you have created a ByteBuffer on the other side of the FFI, do not use this function, use free() instead.

xaynet_ffi_check_settings

Check whether the given settings are valid and can be used to instantiate a participant (see xaynet_ffi_participant_new()).

xaynet_ffi_crypto_init

Initialize the crypto library. This method must be called before instantiating a participant with xaynet_ffi_participant_new() or before generating new keys with xaynet_ffi_generate_key_pair().

xaynet_ffi_forget_key_pair

De-allocate the buffers that contain the signing keys, and zero out the content of the buffer that contains the secret key.

xaynet_ffi_generate_key_pair

Generate a new signing key pair that can be used in the Settings. Before calling this function you must initialize the crypto library with xaynet_ffi_crypto_init().

xaynet_ffi_local_model_config_destroy

Destroy the model configuration created by xaynet_ffi_participant_local_model_config().

xaynet_ffi_participant_destroy

Destroy the participant created by xaynet_ffi_participant_new() or xaynet_ffi_participant_restore().

xaynet_ffi_participant_global_model

Return the latest global model from the coordinator.

xaynet_ffi_participant_local_model_config

Return the local model configuration of the model that is expected in the xaynet_ffi_participant_set_model() function.

xaynet_ffi_participant_new

Instantiate a new participant with the given settings. The participant must be destroyed with xaynet_ffi_participant_destroy.

xaynet_ffi_participant_restore

Restore the participant from a buffer that contained its serialized state.

xaynet_ffi_participant_save

Serialize the participant state and return a buffer that contains the serialized participant.

xaynet_ffi_participant_set_model

Set the participant's model. Usually this should be called when the value returned by xaynet_ffi_participant_tick() contains the PARTICIPANT_SHOULD_SET_MODEL flag, but it can be called anytime. The model just won't be sent to the coordinator until it's time.

xaynet_ffi_participant_tick

Drive the participant internal state machine. Every tick, the state machine attempts to perform a small work unit.

xaynet_ffi_settings_destroy

Destroy the settings created by xaynet_ffi_settings_new().

xaynet_ffi_settings_new

Create new Settings and return a pointer to it.

xaynet_ffi_settings_set_keys

Set participant signing keys.

xaynet_ffi_settings_set_scalar

Set scalar setting.

xaynet_ffi_settings_set_url

Set coordinator URL.