morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::UiClient Class Reference

Opens an application's bundle through the UI service, verifying everything it fetches. More...

#include <service_client.hpp>

Public Types

using Done = std::function<void(std::expected<LoadedBundle, ConnectError>)>
 What open delivers.
using PollDone = std::function<void(std::expected<std::optional<LoadedBundle>, ConnectError>)>
 What poll delivers: the changed bundle, nothing when the digest is the one already held, or why there is none.

Public Member Functions

 UiClient (Exchange exchange, HelloRequest client, std::shared_ptr< IBundleStore > store)
 A client.
void open (::morph::session::Context session, Done done) const
 Opens the bundle. done is called once, from whichever thread the exchange calls back on; a synchronous exchange calls it before open returns.
void poll (::morph::session::Context session, std::string knownDigest, PollDone done) const
 One step of a development client's reload (spec 5 §12): sends ui-hello, and when the manifest digest differs from knownDigest, opens the changed bundle as open does, fetching only what the cache does not hold. done is called once, as open's is.
std::expected< LoadedBundle, ConnectError > openOffline (std::string_view application) const
 Rebuilds the last bundle this store verified for application, without a connection. Files the store no longer holds, or that no longer verify, are left out; the catalog is empty.

Detailed Description

Opens an application's bundle through the UI service, verifying everything it fetches.

open runs ui-hello, refuses a bundle that needs a vocabulary the client does not speak, takes the manifest from the cache or fetches it by the digest and verifies it, runs ui-catalog, and fetches the files the principal may use that the cache does not hold, all at once, verifying each. A file that does not hash to its manifest entry, or a manifest that does not hash to the digest, refuses the whole bundle (Unverified). An unchanged manifest fetches nothing.

Definition at line 250 of file service_client.hpp.

Member Typedef Documentation

◆ Done

using morph::ui::UiClient::Done = std::function<void(std::expected<LoadedBundle, ConnectError>)>

What open delivers.

Definition at line 265 of file service_client.hpp.

◆ PollDone

using morph::ui::UiClient::PollDone = std::function<void(std::expected<std::optional<LoadedBundle>, ConnectError>)>

What poll delivers: the changed bundle, nothing when the digest is the one already held, or why there is none.

Definition at line 278 of file service_client.hpp.

Constructor & Destructor Documentation

◆ UiClient()

morph::ui::UiClient::UiClient ( Exchange exchange,
HelloRequest client,
std::shared_ptr< IBundleStore > store )
inline

A client.

Parameters
exchangeThe transport.
clientWhat the client speaks and carries, sent with ui-hello.
storeWhere verified files are kept.
Exceptions
std::invalid_argumentif exchange is empty or store is null.

Definition at line 257 of file service_client.hpp.

Member Function Documentation

◆ open()

void morph::ui::UiClient::open ( ::morph::session::Context session,
Done done ) const
inline

Opens the bundle. done is called once, from whichever thread the exchange calls back on; a synchronous exchange calls it before open returns.

Parameters
sessionThe session every request carries: the principal's token, or none before sign-in.
doneCalled with the bundle, or why there is none.

Definition at line 271 of file service_client.hpp.

◆ poll()

void morph::ui::UiClient::poll ( ::morph::session::Context session,
std::string knownDigest,
PollDone done ) const
inline

One step of a development client's reload (spec 5 §12): sends ui-hello, and when the manifest digest differs from knownDigest, opens the changed bundle as open does, fetching only what the cache does not hold. done is called once, as open's is.

Parameters
sessionThe session every request carries.
knownDigestThe digest of the bundle the client has, as HelloReply::digest spells it.
doneCalled with the changed bundle, with nothing when the digest is unchanged, or with why the poll failed.

Definition at line 287 of file service_client.hpp.

◆ openOffline()

std::expected< LoadedBundle, ConnectError > morph::ui::UiClient::openOffline ( std::string_view application) const
inlinenodiscard

Rebuilds the last bundle this store verified for application, without a connection. Files the store no longer holds, or that no longer verify, are left out; the catalog is empty.

Parameters
applicationThe application's id.
Returns
The bundle, or Unreachable when no verified manifest is cached.

Definition at line 306 of file service_client.hpp.


The documentation for this class was generated from the following file: