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

Where uploaded and issued files live. Every call names the principal it is made for, and an upload id or a file reference works only for the principal it was made for. More...

#include <file_store.hpp>

Inheritance diagram for morph::ui::IFileStore:
morph::ui::MemoryFileStore

Public Member Functions

 IFileStore (IFileStore const &)=delete
IFileStore & operator= (IFileStore const &)=delete
 IFileStore (IFileStore &&)=delete
IFileStore & operator= (IFileStore &&)=delete
virtual std::expected< std::string, FileError > begin (std::string const &principal, FileInfo info)=0
 Starts an upload.
virtual std::expected< std::size_t, FileError > append (std::string const &principal, std::string const &upload, std::size_t offset, std::string_view bytes)=0
 Appends a chunk to an upload.
virtual std::expected< std::string, FileError > finish (std::string const &principal, std::string const &upload)=0
 Ends an upload and files it.
virtual std::expected< std::string, FileError > issue (std::string const &principal, FileInfo info, std::string bytes)=0
 Files bytes the server made for a principal, such as a report a reply returns.
virtual std::expected< FileSlice, FileError > read (std::string const &principal, std::string const &ref, std::size_t offset, std::size_t length)=0
 Reads a slice of a file.

Detailed Description

Where uploaded and issued files live. Every call names the principal it is made for, and an upload id or a file reference works only for the principal it was made for.

A reference is a capability: whoever presents it, as the principal it belongs to, may read the file. It is therefore unguessable (newFileRef), and a store answers a reference of another principal exactly as one that does not exist.

Definition at line 78 of file file_store.hpp.

Member Function Documentation

◆ begin()

virtual std::expected< std::string, FileError > morph::ui::IFileStore::begin ( std::string const & principal,
FileInfo info )
nodiscardpure virtual

Starts an upload.

Parameters
principalThe uploader.
infoThe file's name, type and size.
Returns
The upload id, or why it was refused.

Implemented in morph::ui::MemoryFileStore.

◆ append()

virtual std::expected< std::size_t, FileError > morph::ui::IFileStore::append ( std::string const & principal,
std::string const & upload,
std::size_t offset,
std::string_view bytes )
nodiscardpure virtual

Appends a chunk to an upload.

Parameters
principalThe uploader.
uploadThe upload id.
offsetWhere the chunk starts: the bytes received so far.
bytesThe chunk.
Returns
The bytes received so far, or why the chunk was refused.

Implemented in morph::ui::MemoryFileStore.

◆ finish()

virtual std::expected< std::string, FileError > morph::ui::IFileStore::finish ( std::string const & principal,
std::string const & upload )
nodiscardpure virtual

Ends an upload and files it.

Parameters
principalThe uploader.
uploadThe upload id.
Returns
The file's reference, or why it was refused.

Implemented in morph::ui::MemoryFileStore.

◆ issue()

virtual std::expected< std::string, FileError > morph::ui::IFileStore::issue ( std::string const & principal,
FileInfo info,
std::string bytes )
nodiscardpure virtual

Files bytes the server made for a principal, such as a report a reply returns.

Parameters
principalThe principal the reference is for.
infoThe file's name and type; size is taken from bytes.
bytesThe file.
Returns
The file's reference, or why it was refused.

Implemented in morph::ui::MemoryFileStore.

◆ read()

virtual std::expected< FileSlice, FileError > morph::ui::IFileStore::read ( std::string const & principal,
std::string const & ref,
std::size_t offset,
std::size_t length )
nodiscardpure virtual

Reads a slice of a file.

Parameters
principalThe reader.
refThe file's reference.
offsetThe first byte.
lengthAt most this many bytes.
Returns
The slice, or why it was refused.

Implemented in morph::ui::MemoryFileStore.


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