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

An IFileStore in memory: bounded per file and per principal; an upload that stalls expires. More...

#include <file_store.hpp>

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

Public Member Functions

 MemoryFileStore (MemoryFileStoreOptions options={})
 A store with options.
std::expected< std::string, FileError > begin (std::string const &principal, FileInfo info) override
 Starts an upload.
std::expected< std::size_t, FileError > append (std::string const &principal, std::string const &upload, std::size_t offset, std::string_view bytes) override
 Appends a chunk.
std::expected< std::string, FileError > finish (std::string const &principal, std::string const &upload) override
 Ends an upload and files it.
std::expected< std::string, FileError > issue (std::string const &principal, FileInfo info, std::string bytes) override
 Files bytes for a principal.
std::expected< FileSlice, FileError > read (std::string const &principal, std::string const &ref, std::size_t offset, std::size_t length) override
 Reads a slice.
Public Member Functions inherited from morph::ui::IFileStore
 IFileStore (IFileStore const &)=delete
IFileStore & operator= (IFileStore const &)=delete
 IFileStore (IFileStore &&)=delete
IFileStore & operator= (IFileStore &&)=delete

Detailed Description

An IFileStore in memory: bounded per file and per principal; an upload that stalls expires.

Thread-safe: the UI service calls it on the server strand while an application issues references from its models'.

Definition at line 164 of file file_store.hpp.

Constructor & Destructor Documentation

◆ MemoryFileStore()

morph::ui::MemoryFileStore::MemoryFileStore ( MemoryFileStoreOptions options = {})
inlineexplicit

A store with options.

Parameters
optionsThe bounds and the clock.

Definition at line 168 of file file_store.hpp.

Member Function Documentation

◆ begin()

std::expected< std::string, FileError > morph::ui::MemoryFileStore::begin ( std::string const & principal,
FileInfo info )
inlinenodiscardoverridevirtual

Starts an upload.

Parameters
principalThe uploader.
infoThe file's name, type and size.
Returns
The upload id, or TooLarge or OverQuota.

Implements morph::ui::IFileStore.

Definition at line 174 of file file_store.hpp.

◆ append()

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

Appends a chunk.

Parameters
principalThe uploader.
uploadThe upload id.
offsetThe bytes received so far.
bytesThe chunk.
Returns
The bytes received so far, or NotFound, BadOffset or TooLarge (past the announced size).

Implements morph::ui::IFileStore.

Definition at line 195 of file file_store.hpp.

◆ finish()

std::expected< std::string, FileError > morph::ui::MemoryFileStore::finish ( std::string const & principal,
std::string const & upload )
inlinenodiscardoverridevirtual

Ends an upload and files it.

Parameters
principalThe uploader.
uploadThe upload id.
Returns
The reference, or NotFound or Incomplete.

Implements morph::ui::IFileStore.

Definition at line 219 of file file_store.hpp.

◆ issue()

std::expected< std::string, FileError > morph::ui::MemoryFileStore::issue ( std::string const & principal,
FileInfo info,
std::string bytes )
inlinenodiscardoverridevirtual

Files bytes for a principal.

Parameters
principalThe principal.
infoThe name and type.
bytesThe file.
Returns
The reference, or TooLarge or OverQuota.

Implements morph::ui::IFileStore.

Definition at line 244 of file file_store.hpp.

◆ read()

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

Reads a slice.

Parameters
principalThe reader.
refThe reference.
offsetThe first byte.
lengthAt most this many bytes.
Returns
The slice (empty past the end), or NotFound.

Implements morph::ui::IFileStore.

Definition at line 266 of file file_store.hpp.


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