Module safe_core::ffi
[−]
[src]
Ffi module;
This module provides FFI-bindings to the Client Modules (core
, nfs
, dns
)
In the current implementation the allocations made by this crate are managed within the crate
itself and is guaranteed that management of such allocations will not be pushed beyond the FFI
boundary. This has a 2-fold outcome: firstly, the passing of data is done by filling of the
allocations passed by the caller and is caller's responsibility to manage those. For this every
function that fills an allocated memory also has a companion function to return the size of
data which the caller can call to find out how much space needs to be allocated in the first
place. Second and consequently, the caller does not have to bother calling functions within
this crate which only serve to free resources allocated by the crate itself. This otherwise
would be error prone and cumbersome. Instead the caller can use whatever idiom in his language
to manage memory much more naturally and conveniently (eg., RAII idioms etc)
The only exception to the above rule is the obtainment of the client engine itself. The client
engine is allocated and managed by the crate. This is necessary because it serves as a context
to all operations provided by the crate. Hence the user will obtain the engine on calling any
one of the functions to create it and must preserve it for all subsequent operations. When
done, to release the resources, drop_client
may be called.
Modules
errors |
Errors thrown by the FFI operations |
Structs
FfiHandle |
A handle, passed through the FFI. |
ParameterPacket |
ParameterPacket acts as a holder for the standard parameters that would be needed for performing operations across the modules like nfs and dns |
Traits
Action |
ICommand trait |
Functions
client_issued_deletes |
Return the amount of calls that were done to |
client_issued_gets |
Return the amount of calls that were done to |
client_issued_posts |
Return the amount of calls that were done to |
client_issued_puts |
Return the amount of calls that were done to |
create_account |
Create a registered client. This or any one of the other companion functions to get a
client must be called before initiating any operation allowed by this crate. |
create_unregistered_client |
Create an unregistered client. This or any one of the other companion functions to get a client must be called before initiating any operation allowed by this crate. |
drop_client |
Discard and clean up the previously allocated client. Use this only if the client is obtained
from one of the client obtainment functions in this crate ( |
drop_vector |
Drop the vector returned as a result of the execute_for_content fn |
execute |
General function that can be invoked for performing a API specific operation that will return
only result to indicate whether the operation was successful or not.
This function would only perform the operation and return 0 or error code
c_payload refers to the JSON payload that can be passed as a JSON string.
The JSON string should have keys module, action, app_root_dir_key, safe_drive_dir_key,
safe_drive_access and data. |
execute_for_content |
General function that can be invoked for getting data as a resut for an operation. The function return a pointer to a U8 vecotr. The size of the U8 vector and its capacity is written to the out params c_size & c_capacity. The size and capcity would be required for droping the vector The result of the execution is returned in the c_result out param |
get_account_info |
Get data from the network. This is non-blocking. |
get_app_dir_key |
Returns key size |
get_nfs_writer |
Obtain NFS writer handle for writing data to a file in streaming mode |
get_safe_drive_key |
Returns Key as base64 string |
init_logging |
This function should be called to enable logging to a file |
log_in |
Log into a registered client. This or any one of the other companion functions to get a
client must be called before initiating any operation allowed by this crate. |
nfs_create_file |
Create a file and return a writer for it. |
nfs_stream_close |
Closes the NFS Writer handle |
nfs_stream_write |
Write data to the Network using the NFS Writer handle |
register_network_event_observer |
Register an observer to network events like Connected, Disconnected etc. as provided by the core module |
Type Definitions
ResponseType |
ResponseType specifies the standard Response that is to be expected from the Action trait |