Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.md text eol=lf
29 changes: 17 additions & 12 deletions landing/src/content/docs/Getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ which to name.

## Choosing an engine

Five engines can hold the store, and exactly one of them opens the file. Cargo
features decide which of the five are built in at all; which one takes the file
is said when the store is opened, through `StoreBuilder::backend`. Say nothing
Six engines can hold the store, and exactly one of them holds a given store.
Cargo features decide which of the six are built in at all; which one takes the
store is said when it is opened, through `StoreBuilder::backend`. Say nothing
and the first one built in takes it.

| feature | engine | file |
| feature | engine | where it lives |
| --- | --- | --- |
| `redb` | redb | `.redb` |
| `sqlite` | SQLite | `.db` |
| `json` | JSON | `.json` |
| `toml` | TOML | `.toml` |
| `ron` | RON | `.ron` |
| `redb` | redb | a `.redb` file |
| `sqlite` | SQLite | a `.db` file |
| `json` | JSON | a `.json` file |
| `toml` | TOML | a `.toml` file |
| `ron` | RON | a `.ron` file |
| `localstorage` | the browser's localStorage | keys under `amethystate.<store name>.` in the page |

**The text engines write two files**: the data, and a `.meta` sidecar. The
sidecar carries what the store needs in order to read the data back - which
Expand All @@ -45,15 +46,18 @@ A build with no engine in it still compiles, and a store opened in it is
refused: `StoreBuilder::build` answers `OpenStore::WouldNotOpen`, naming the
features to turn on.

The `memory` feature adds a sixth engine with no file at all. It never takes a
The `memory` feature adds one more engine, with no file at all. It never takes a
store on its own: it is asked for by name, or stands in for a file that will
not open - see [Opening a store](/amethystate/store/opening/#or-running-in-memory).

### In a browser

A page built for `wasm32-unknown-unknown` has no files, and the `localstorage`
feature is the engine for it: the browser's localStorage, one JSON value per
key, readable in the developer tools. Anywhere but a page the open is refused.
key, readable in the developer tools. A write lands in the call that makes it,
with no debounce, and a full quota comes back as the error of that `set`. A
write another tab makes arrives as a change from outside, the way an edit to a
text engine's file does. Anywhere but a page the open is refused.

```toml
amethystate = { version = "0.22", features = ["localstorage"] }
Expand All @@ -62,7 +66,8 @@ amethystate = { version = "0.22", features = ["localstorage"] }
### Several engines at once

Engine features are additive, and when more than one is built in, a store that
names no engine opens with the first of **redb, SQLite, JSON, TOML, RON**. A
names no engine opens with the first of **redb, SQLite, JSON, TOML, RON,
localStorage**. A
dependency that turns on `redb` somewhere in the tree therefore puts redb in
charge of such a store, whatever your own crate asked for.

Expand Down
32 changes: 18 additions & 14 deletions landing/src/content/docs/ru/Getting-started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ amethystate = { version = "0.22", features = ["redb"] }

## Выбор движка

Хранилище могут держать пять движков, и ровно один из них открывает файл. Фичи
Cargo решают, какие из пяти вообще войдут в сборку; какой возьмётся за файл —
говорят при открытии, через `StoreBuilder::backend`. Если не сказать, берётся
первый включённый.
Хранилище могут держать шесть движков, и каждый store держит ровно один из них.
Фичи Cargo решают, какие из шести вообще войдут в сборку; какой возьмётся за
store — говорят при открытии, через `StoreBuilder::backend`. Если не сказать,
берётся первый включённый.

| feature | движок | файл |
| feature | движок | где лежит |
| --- | --- | --- |
| `redb` | redb | `.redb` |
| `sqlite` | SQLite | `.db` |
| `json` | JSON | `.json` |
| `toml` | TOML | `.toml` |
| `ron` | RON | `.ron` |
| `redb` | redb | файл `.redb` |
| `sqlite` | SQLite | файл `.db` |
| `json` | JSON | файл `.json` |
| `toml` | TOML | файл `.toml` |
| `ron` | RON | файл `.ron` |
| `localstorage` | localStorage браузера | ключи под `amethystate.<имя store>.` на странице |

**Текстовые движки пишут два файла**: данные и файл-спутник `.meta`. В спутнике
лежит то, без чего store не прочитает данные обратно: какая версия каждой
Expand All @@ -45,16 +46,18 @@ Cargo решают, какие из пяти вообще войдут в сбо
`StoreBuilder::build` ответит `OpenStore::WouldNotOpen` и назовёт фичи, которые
надо включить.

Фича `memory` добавляет шестой движок — вовсе без файла. Сам он store не
Фича `memory` добавляет ещё один движок — вовсе без файла. Сам он store не
берёт никогда: его просят по имени, или он встаёт на место файла, который не
открылся, — см. [Открытие store](/amethystate/ru/store/opening/#или-работать-в-памяти).

### В браузере

У страницы, собранной под `wasm32-unknown-unknown`, файлов нет, и движок для
неё — фича `localstorage`: localStorage браузера, по значению JSON на ключ, и
всё это видно в инструментах разработчика. Где угодно, кроме страницы, store не
откроется.
всё это видно в инструментах разработчика. Запись ложится сразу, в том же
вызове, без дебаунса, а переполненная квота приходит ошибкой этого `set`.
Запись из другой вкладки приходит как изменение со стороны — так же, как правка
файла текстового движка. Где угодно, кроме страницы, store не откроется.

```toml
amethystate = { version = "0.22", features = ["localstorage"] }
Expand All @@ -63,7 +66,8 @@ amethystate = { version = "0.22", features = ["localstorage"] }
### Несколько движков сразу

Фичи Cargo аддитивны. Если в сборке несколько движков, store, которому движок
не назвали, берёт тот, что раньше в списке **redb, SQLite, JSON, TOML, RON**.
не назвали, берёт тот, что раньше в списке **redb, SQLite, JSON, TOML, RON,
localStorage**.
Так что стоит какой-нибудь зависимости включить `redb`, и за такой store
возьмётся redb, что бы ни просил ваш крейт.

Expand Down
Loading