Proto commits in scottlamb/moonfire-nvr

These 13 commits are when the Protocol Buffers files have changed:

Commit:a4bc7f5
Author:Scott Lamb
Committer:Scott Lamb

config file reference and doc reorganization

The documentation is generated from this commit.

Commit:42fe054
Author:Scott Lamb
Committer:Scott Lamb

make `GET /api/` return current permissions This is useful for e.g. deciding whether or not to present the user admin UI in navigation. As part of this change, I adjusted the casing in Permissions, and then all the toml stuff for consistency. Noted in changelog.

Commit:be4e11c
Author:Scott Lamb
Committer:Scott Lamb

extend POST /users/:id Now you can set a password for a user while the server is running, e.g. via the following command: ```shell curl \ -H 'Content-Type: application/json' \ -d '{"update": {"password": "asdf"}}' \ --unix-socket /var/lib/moonfire-nvr/sock \ http://nvr/api/users/1 ```

Commit:2936c13
Author:Scott Lamb

various doc improvements I bumped the minimum Rust version because I'm taking advantage of the rustdoc linking added in Rust 1.48: https://blog.rust-lang.org/2020/11/19/Rust-1.48.html#easier-linking-in-rustdoc

Commit:c547a49
Author:Scott Lamb
Committer:Scott Lamb

shorten per-file copyright headers I'm tired of all the boilerplate, so use the new GPL-3.0-linking-exception license identifier instead in all the server components. I left the ui stuff alone because I'm just going to replace it (#111). Add a checker for the header because it's easy to forget.

Commit:dd66c7b
Author:Scott Lamb
Committer:Scott Lamb

restructure into "server" and "ui" subdirs Besides being more clear about what belongs to which, this helps with docker caching. The server and ui parts are only rebuilt when their respective subdirectories change. Extend this a bit further by making the webpack build not depend on the target architecture. And adding cache dirs so parts of the server and ui build process can be reused when layer-wide caching fails.

Commit:317a620
Author:Scott Lamb

upgrade copyright notices * As discussed in #48, say "The Moonfire NVR Authors" at the top of every file rather than whoever created that file. Have one AUTHORS file listing everyone. * Consistently call it a "security camera network video recorder" rather than "security camera digital video recorder".

Commit:d61b5e1
Author:Scott Lamb
Committer:Scott Lamb

Use fixed-size directory meta files Add a new schema version 5; now 4 means the directory meta may or may not be upgraded. Fixes #65: now it's possible to open the directory even if it lies on a completely full disk.

Commit:fda7e4c
Author:Scott Lamb
Committer:Scott Lamb

add concept of user/session permissions (I also considered the names "capabilities" and "scopes", but I think "permissions" is the most widely understood.) This is increasingly necessary as the web API becomes more capable. Among other things, it allows: * non-administrator users who can view but not access camera passwords or change any state * workers that update signal state based on cameras' built-in motion detection or a security system's events but don't need to view videos * control over what can be done without authenticating Currently session permissions are just copied from user permissions, but you can also imagine admin sessions vs not, as a checkbox when signing in. This would match the standard Unix workflow of using a non-administrative session most of the time. Relevant to my current signals work (#28) and to the addition of an administrative API (#35, including #66).

Commit:65e68d3
Author:Scott Lamb

update design docs for new-schema branch changes

Commit:0f2e71e
Author:Scott Lamb

more safety around adding/deleting dirs

Commit:31adbc1
Author:Scott Lamb

initial split of database to a separate crate It should reduce compile time / memory usage to put quite a bit of the code into a separate crate. I also intend to limit visibility of some things to only within the db crate, but that's for a future change. This is the smallest move that will compile.

Commit:e7f5733
Author:Scott Lamb
Committer:Scott Lamb

new database/sample file dir interlock scheme The idea is to avoid the problems described in src/schema.proto; those possibilities have bothered me for a while. A bonus is that (in a future commit) it can replace the sample file uuid scheme in favor of using <camera_uuid>-<stream_type>/<recording_id> for several advantages: * on data integrity problems (specifically, extra sample files), more information to use to understand what happened. * no more reserving sample files prior to using them. This avoids some extra database transactions on startup (now there's an extra two total rather than an extra one per stream). It also simplifies an upcoming change I want to make in which some streams are not flushed immediately, reducing the write load significantly (maybe one per minute total rather than one per stream per minute). * get rid of eight bytes per playback cache entry in RAM (and nine bytes per recording_playback row on flash). The implementation is still pretty rough in places: * Lack of tests. * Poor ode organization. In particular, SampleFileDirectory::write_meta shouldn't be exposed beyond db. I'm thinking about moving db.rs and SampleFileDirectory to a new crate, moonfire_nvr_db. This would improve compile times as well. * No tooling for renaming a sample file directory. * Config subcommand still panics in conditions that can be reasonably expected to happen.