# bookclerk_library::entities::edition_files

SeaORM entity for `edition_files`: every file key an acquire or a host
upload wrote, per output destination, and the edition it belongs to
(library data model ADR, `docs/adr/library-data-model.md`,
section 3). Written by the acquire pipeline
([`crate::LibraryStore::record_edition_file`](/docs/internals/crates/bookclerk_library/index.md#librarystorerecord_edition_file)) and by
`control_plane::uploads`, which refuses an upload a key another edition
holds and deletes an aborted upload's copy only while the key is still
its own.

| Item | Kind | Summary |
| --- | --- | --- |
| [`Model`](#model) | struct | Row shape for one recorded file key. |
| [`ColumnIter`](#columniter) | struct | An iterator over the variants of [Column] |
| [`Entity`](#entity) | struct | Generated by sea-orm-macros |
| [`PrimaryKeyIter`](#primarykeyiter) | struct | An iterator over the variants of [PrimaryKey] |
| [`ActiveModel`](#activemodel) | struct | Generated by sea-orm-macros |
| [`RelationIter`](#relationiter) | struct | An iterator over the variants of [Relation] |
| [`Column`](#column) | enum | Generated by sea-orm-macros |
| [`PrimaryKey`](#primarykey) | enum | Generated by sea-orm-macros |
| [`Relation`](#relation) | enum | Declared SeaORM relations (none). |

## Structs

### Model

```rust
pub struct Model {
    pub destination: String,
    pub storage_key: String,
    pub owner_kind: String,
    pub owner_id: String,
    pub role: String,
    pub lossless: i64,
    pub bitrate_kbps: Option<i64>,
    pub content_type: Option<String>,
    pub source_store: Option<String>,
    pub probed_at: Option<String>,
    pub sha256: Option<String>,
    pub copy_format: Option<String>,
    pub copy_quality: Option<String>,
    pub codec: Option<String>,
    pub aac_profile: Option<String>,
    pub channels: Option<i64>,
    pub sample_rate_hz: Option<i64>,
    pub duration_ms: Option<i64>,
    pub writer: String,
    pub written_at: String,
}
```

Row shape for one recorded file key.

**Fields**

- `destination`: Output destination id (`local`, `s3`).
- `storage_key`: Storage key on that destination.
- `owner_kind`: `edition`: files belong to editions.
- `owner_id`: The edition id.
- `role`: What the file is ([`crate::FileRole`](/docs/internals/crates/bookclerk_library/index.md#filerole)).
- `lossless`: 1 for a lossless audio encoding; 0 otherwise or unknown (an integer,
  as every flag column is, so each database adapter decodes it alike).
- `bitrate_kbps`: Average audio bitrate in kilobits per second, once probed.
- `content_type`: Media type of the file (`audio/mp4`, `audio/mpeg`, `audio/flac`),
  once probed.
- `source_store`: Plain id of the storefront the copy was downloaded from (`audible`,
  `libro`), when the writer knew it.
- `probed_at`: RFC 3339 time the probe result was stored; `None` until the file has
  been probed.
- `sha256`: Lowercase hex SHA-256 of the content, when known (host uploads).
- `copy_format`: Format of the library copy (`output.copies`) this audio file belongs
  to (`m4b`, `mp3`, `mp3_chapters`, `original`); `None` for a file of
  no one copy (a sidecar, the PDF) or an upload.
- `copy_quality`: Quality of that copy (`original`, `64k-mono`, `v2`); `None` exactly
  when [`Self::copy_format`](#model) is.
- `codec`: The audio encoding a probe found (`aac`, `mp3`, `opus`, ...), once
  probed and when the tag reader knows it.
- `aac_profile`: The AAC profile (`lc`, `he`, `he_v2`, `xhe`) of an AAC file whose
  decoder configuration names one.
- `channels`: Output channels, when the headers state them.
- `sample_rate_hz`: Output sample rate in hertz, when the headers state it.
- `duration_ms`: The running time a player sees, in milliseconds; null when unknown,
  never zero.
- `writer`: The host upload id that claimed the key last, or
  [`crate::store::ACQUIRE_WRITER`](/docs/internals/crates/bookclerk_library/index.md#acquire_writer) for an acquire run on this node.
- `written_at`: RFC 3339 time of the latest claim.

#### Model::into_ex

```rust
pub fn into_ex(self) -> Self
```

Generated by sea-orm-macros

Implements: `Clone`, `Debug`, `Eq`, `From<Model>`, `FromQueryResult`, `IntoActiveModel<ActiveModel>`, `ModelTrait`, `PartialEq`, `TryFrom<ActiveModel>`, `TryIntoModel<Model>`

### ColumnIter

```rust
pub struct ColumnIter {
    /* private fields */
}
```

An iterator over the variants of [Column](#column)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

### Entity

```rust
pub struct Entity;
```

Generated by sea-orm-macros

Implements: `Clone`, `Copy`, `Debug`, `Default`, `EntityName`, `EntityTrait`, `Iden`, `IdenStatic`

### PrimaryKeyIter

```rust
pub struct PrimaryKeyIter {
    /* private fields */
}
```

An iterator over the variants of [PrimaryKey](#primarykey)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

### ActiveModel

```rust
pub struct ActiveModel {
    pub destination: ActiveValue<String>,
    pub storage_key: ActiveValue<String>,
    pub owner_kind: ActiveValue<String>,
    pub owner_id: ActiveValue<String>,
    pub role: ActiveValue<String>,
    pub lossless: ActiveValue<i64>,
    pub bitrate_kbps: ActiveValue<Option<i64>>,
    pub content_type: ActiveValue<Option<String>>,
    pub source_store: ActiveValue<Option<String>>,
    pub probed_at: ActiveValue<Option<String>>,
    pub sha256: ActiveValue<Option<String>>,
    pub copy_format: ActiveValue<Option<String>>,
    pub copy_quality: ActiveValue<Option<String>>,
    pub codec: ActiveValue<Option<String>>,
    pub aac_profile: ActiveValue<Option<String>>,
    pub channels: ActiveValue<Option<i64>>,
    pub sample_rate_hz: ActiveValue<Option<i64>>,
    pub duration_ms: ActiveValue<Option<i64>>,
    pub writer: ActiveValue<String>,
    pub written_at: ActiveValue<String>,
}
```

Generated by sea-orm-macros

**Fields**

- `destination`: Generated by sea-orm-macros
- `storage_key`: Generated by sea-orm-macros
- `owner_kind`: Generated by sea-orm-macros
- `owner_id`: Generated by sea-orm-macros
- `role`: Generated by sea-orm-macros
- `lossless`: Generated by sea-orm-macros
- `bitrate_kbps`: Generated by sea-orm-macros
- `content_type`: Generated by sea-orm-macros
- `source_store`: Generated by sea-orm-macros
- `probed_at`: Generated by sea-orm-macros
- `sha256`: Generated by sea-orm-macros
- `copy_format`: Generated by sea-orm-macros
- `copy_quality`: Generated by sea-orm-macros
- `codec`: Generated by sea-orm-macros
- `aac_profile`: Generated by sea-orm-macros
- `channels`: Generated by sea-orm-macros
- `sample_rate_hz`: Generated by sea-orm-macros
- `duration_ms`: Generated by sea-orm-macros
- `writer`: Generated by sea-orm-macros
- `written_at`: Generated by sea-orm-macros

Implements: `ActiveModelBehavior`, `ActiveModelTrait`, `Clone`, `Debug`, `Default`, `From<Model>`, `IntoActiveModel<ActiveModel>`, `PartialEq`, `TryFrom<ActiveModel>`, `TryIntoModel<Model>`

### RelationIter

```rust
pub struct RelationIter {
    /* private fields */
}
```

An iterator over the variants of [Relation](#relation)

Implements: `Clone`, `Debug`, `DoubleEndedIterator`, `ExactSizeIterator`, `FusedIterator`, `Iterator`

## Enums

### Column

```rust
pub enum Column {
    Destination,
    StorageKey,
    OwnerKind,
    OwnerId,
    Role,
    Lossless,
    BitrateKbps,
    ContentType,
    SourceStore,
    ProbedAt,
    Sha256,
    CopyFormat,
    CopyQuality,
    Codec,
    AacProfile,
    Channels,
    SampleRateHz,
    DurationMs,
    Writer,
    WrittenAt,
}
```

Generated by sea-orm-macros

**Variants**

- `Destination`: Generated by sea-orm-macros
- `StorageKey`: Generated by sea-orm-macros
- `OwnerKind`: Generated by sea-orm-macros
- `OwnerId`: Generated by sea-orm-macros
- `Role`: Generated by sea-orm-macros
- `Lossless`: Generated by sea-orm-macros
- `BitrateKbps`: Generated by sea-orm-macros
- `ContentType`: Generated by sea-orm-macros
- `SourceStore`: Generated by sea-orm-macros
- `ProbedAt`: Generated by sea-orm-macros
- `Sha256`: Generated by sea-orm-macros
- `CopyFormat`: Generated by sea-orm-macros
- `CopyQuality`: Generated by sea-orm-macros
- `Codec`: Generated by sea-orm-macros
- `AacProfile`: Generated by sea-orm-macros
- `Channels`: Generated by sea-orm-macros
- `SampleRateHz`: Generated by sea-orm-macros
- `DurationMs`: Generated by sea-orm-macros
- `Writer`: Generated by sea-orm-macros
- `WrittenAt`: Generated by sea-orm-macros

Implements: `Clone`, `ColumnTrait`, `Copy`, `Debug`, `FromStr`, `Iden`, `IdenStatic`, `IntoEnumIterator`

### PrimaryKey

```rust
pub enum PrimaryKey {
    Destination,
    StorageKey,
}
```

Generated by sea-orm-macros

**Variants**

- `Destination`: Generated by sea-orm-macros
- `StorageKey`: Generated by sea-orm-macros

Implements: `Clone`, `Copy`, `Debug`, `Iden`, `IdenStatic`, `IntoEnumIterator`, `PrimaryKeyToColumn`, `PrimaryKeyTrait`

### Relation

```rust
pub enum Relation {}
```

Declared SeaORM relations (none).

Implements: `Clone`, `Copy`, `Debug`, `IntoEnumIterator`, `RelationTrait`
