Rephrase architecture doc.
This commit is contained in:
parent
b942b9702d
commit
6068f2b52d
1 changed files with 23 additions and 17 deletions
|
@ -1,7 +1,8 @@
|
||||||
# Architecture of the imag code
|
# Architecture of the imag code
|
||||||
|
|
||||||
The imag codebase has a rather simple overall architecture. But before
|
The imag codebase has a rather simple overall architecture.
|
||||||
introducing the reader to it, a few things have to be introduced.
|
In this chapter the types of crates, architecture of an imag module
|
||||||
|
and the type structure are described.
|
||||||
|
|
||||||
## Crate types
|
## Crate types
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ project.
|
||||||
First of all, there are core crates. These crates provide the very core of imag
|
First of all, there are core crates. These crates provide the very core of imag
|
||||||
and almost all other crates use them:
|
and almost all other crates use them:
|
||||||
|
|
||||||
* libimagstore - The imag store is the abstraction overbthe filesystem. It
|
* libimagstore - The imag store is the abstraction over the filesystem. It
|
||||||
provides primitives to get, write and manipulate store entries and their
|
provides primitives to get, write and manipulate store entries and their
|
||||||
header information.
|
header information.
|
||||||
* libimagrt - The runtime library, which provides functionality to create a
|
* libimagrt - The runtime library, which provides functionality to create a
|
||||||
|
@ -27,13 +28,15 @@ extensional functionality for the types from libimagstore. For example, there is
|
||||||
"libimagentrylink" which provides functionality to link two entries in the
|
"libimagentrylink" which provides functionality to link two entries in the
|
||||||
store.
|
store.
|
||||||
|
|
||||||
The next kind of crate is the one that offers end-user functionality for a imag
|
The third kind of crate is the one that offers end-user functionality for a imag
|
||||||
aspect, for example "libimagtodo" provides functionality to track todos.
|
domain, for example "libimagtodo" provides functionality to track todos.
|
||||||
|
|
||||||
And last, but not least, the commandline frontend crates provide the user
|
And last, but not least, the commandline frontend crates provide the user
|
||||||
interface. These are the kind of crates that are not library crates, but
|
interface. These are the kind of crates that are not library crates, but
|
||||||
binaries.
|
binaries.
|
||||||
|
|
||||||
|
Besides these, there are some other utility crates.
|
||||||
|
|
||||||
## Architecture of an imag module
|
## Architecture of an imag module
|
||||||
|
|
||||||
With the things from above, a module could have the following architecture:
|
With the things from above, a module could have the following architecture:
|
||||||
|
@ -62,24 +65,29 @@ With the things from above, a module could have the following architecture:
|
||||||
+-----------------------------------+---------+
|
+-----------------------------------+---------+
|
||||||
```
|
```
|
||||||
|
|
||||||
The foundation of all imag modules is the store, as one can see from the image.
|
The foundation of all imag modules is the store, as one can see in the image.
|
||||||
Above this there is the libimagrt, which provides the basic runtime and access
|
Above the store library there is the libimagrt, which provides the basic runtime
|
||||||
to the `Store` object. Cross-cutting, there is the error library (and possibly
|
and access to the `Store` object.
|
||||||
|
Cross-cutting, there is the error library (and possibly
|
||||||
the util library, but we do not care about this one here), which is used through
|
the util library, but we do not care about this one here), which is used through
|
||||||
all levels. The highest level of all imag modules is the commandline interface
|
all levels. The highest level of all imag modules is the commandline interface
|
||||||
on top of the domain library. In between can be any number of entry extension
|
on top of the domain library. In between can be any number of entry extension
|
||||||
libraries, or none if not needed.
|
libraries, or none if not needed.
|
||||||
|
|
||||||
|
Theoretically, the commandline interface crate could be replaced to build a
|
||||||
|
terminal user interface, graphical user interface or web interface.
|
||||||
|
|
||||||
## Types
|
## Types
|
||||||
|
|
||||||
The imag core, hence the libimagstore, libimagrt and libimagerror, provide a set
|
The imag core, hence the libimagstore, libimagrt and libimagerror, provide a set
|
||||||
of types that a user (as in a library writer) should be aware of.
|
of types that a user (as in a library writer) should be aware of.
|
||||||
|
|
||||||
First of all, there is the Runtime type which is provided by the libimagrt. It
|
First of all, there is the `Runtime` type which is provided by the libimagrt. It
|
||||||
provides basic access to whether debugging or verbosity is enabled as well as
|
provides basic access to whether debugging or verbosity is enabled as well as
|
||||||
the most important core object: The `Store`.
|
the most important core object: The `Store`.
|
||||||
|
|
||||||
It is provided by the libimagstore library, the heart of everything.
|
The `Store` type is provided by the libimagstore library, the heart of
|
||||||
|
everything.
|
||||||
|
|
||||||
When interacting with the store, two types are visible: `FileLockEntry` and
|
When interacting with the store, two types are visible: `FileLockEntry` and
|
||||||
`Entry` whereas the former derefs to the latter, which basically means that the
|
`Entry` whereas the former derefs to the latter, which basically means that the
|
||||||
|
@ -93,13 +101,11 @@ header and so on. Extensions for its functionality are implemented on this type,
|
||||||
not on the `FileLockEntry`.
|
not on the `FileLockEntry`.
|
||||||
|
|
||||||
The `Entry` provides access to its header, which is a `toml::Value`, where toml
|
The `Entry` provides access to its header, which is a `toml::Value`, where toml
|
||||||
is the toml-rs crate (external project). Conveniance functionality is provided
|
is the toml-rs crate (external project). Convenience functionality is provided
|
||||||
via the `toml-query` crate, which is an external project which was initiated and
|
via the `toml-query` crate, which is an external project which was initiated and
|
||||||
extracted from the imag project.
|
extracted from the imag project.
|
||||||
|
|
||||||
Error types are also important. All errors in the imag prijects are generated by
|
Error types are also important.
|
||||||
libimagerror usage and are interoperable. User code hardly handles the actual
|
All errors in imag projects should be created with `error-chain`.
|
||||||
`Error` type but its inner one, `ErrorKind`, which is an enum where each member
|
libimagerror provides functionality to enhance the experience with `Result`
|
||||||
can be mapped to a representing text. Imag error types do never contain payload
|
types and general tracing of errors.
|
||||||
(they can via extensions, though it is not really practical and there is no
|
|
||||||
usage for it).
|
|
||||||
|
|
Loading…
Reference in a new issue