Provide application-specific Client types

Description

This task supersedes https://maidsafe.atlassian.net/browse/MAID-2718#icft=MAID-2718 (see the task description and comments for details).

Remove the ClientType struct from safe_core::client and provide application-specific Client types. This will decouple safe_core from safe_auth and safe_app as the current design assumes the existence of those libraries.

Details:

  • Replace the current Client struct with a Client trait in safe_core. The methods from the current struct can be moved to the new trait with their implementations intact.

  • Create application-specific clients for safe_authenticator (RegisteredClient) and safe_app (UnregisteredClient and KeysClient) which implement the Client trait.

  • Move the authenticator-specific code from safe_core::client into RegisteredClient. For example, functions like Client::set_access_container or Client::update_account_packet.

  • Also create a new CoreClient struct internal to safe_core, for use in testing. It should be a barebones implementation of the Client trait.

  • The current Client constructors (e.g. registered and unregistered) should be moved to the appropriate new application-specific Client struct. The constructors should be marked pub(crate) so that other applications cannot initialize instances of the Client but they are still public within the crate.

  • Publically-exported functions in safe_core that currently take a Client parameter should take a generic parameter that implements Client.

  • Make safe_core::event_loop::run take a generic client instead of a given Client struct.

  • In safe_app, only export UnregisteredClient and KeysClient (with its constructors only public within the crate). The Client trait will have an implementation for the new constructor, which we don't want to export.

  • Update all tests that use the current API.

  • Update documentation for all affected functions and structs.

Misc changes:

  • Move the Client::sign_pk_from_seed function from impl Client into a standalone function in safe_core::lib.rs, as this is a "static method" which has no real reason to be associated with Client.

Environment

None

Activity

Marcin Swieczkowski July 2, 2018 at 4:18 PM

Changed the end date from Monday to Friday to give a couple extra days to get this implemented correctly and thoroughly reviewed.

Done

Details

Assignee

Reporter

Start date

End date

Story Points

Components

Priority

Created June 26, 2018 at 3:33 PM
Updated July 12, 2018 at 11:13 PM
Resolved July 12, 2018 at 11:13 PM