# bookclerk_library::entities::edition_copies

SeaORM entity for `edition_copies`: each edition's copy at each output
destination and where it stands (storage destinations ADR,
`docs/adr/storage-destinations.md`, decision 3).

Written by the acquire pipeline once each destination's write ends
([`crate::LibraryStore::set_copy_stored`](/docs/internals/crates/bookclerk_library/index.md#librarystoreset_copy_stored),
[`crate::LibraryStore::set_copy_pending`](/docs/internals/crates/bookclerk_library/index.md#librarystoreset_copy_pending)) and by a host upload's commit
on the owner; read by acquire candidate selection, which visits an
acquired edition again while a destination that takes it lacks a stored
copy.

| Item | Kind | Summary |
| --- | --- | --- |
| [`Model`](#model) | struct | Row shape for this table (`DeriveEntityModel`). |
| [`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 unless FK edges are modeled). |

## Structs

### Model

```rust
pub struct Model {
    pub edition_id: String,
    pub destination: String,
    pub state: String,
    pub storage_key: Option<String>,
    pub attempts: i64,
    pub next_attempt_at: Option<String>,
    pub last_error: Option<String>,
    pub updated_at: String,
}
```

Row shape for this table (`DeriveEntityModel`).

**Fields**

- `edition_id`: The edition (`editions.id`).
- `destination`: The destination's plugin instance id.
- `state`: Where the copy stands (`CopyState::as_str`): `stored`, `pending`, `missing` or
  `failed`.
- `storage_key`: The edition's primary audio key on this destination; set once
  stored, and kept from an earlier stored copy while a later write is
  retried.
- `attempts`: Failed writes since the copy was last stored (0 once stored).
- `next_attempt_at`: RFC 3339 time the next background attempt is due; `None` unless
  pending.
- `last_error`: The last write failure, for operators; `None` once stored.
- `updated_at`: RFC 3339 timestamp when the row was last modified.

#### 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 edition_id: ActiveValue<String>,
    pub destination: ActiveValue<String>,
    pub state: ActiveValue<String>,
    pub storage_key: ActiveValue<Option<String>>,
    pub attempts: ActiveValue<i64>,
    pub next_attempt_at: ActiveValue<Option<String>>,
    pub last_error: ActiveValue<Option<String>>,
    pub updated_at: ActiveValue<String>,
}
```

Generated by sea-orm-macros

**Fields**

- `edition_id`: Generated by sea-orm-macros
- `destination`: Generated by sea-orm-macros
- `state`: Generated by sea-orm-macros
- `storage_key`: Generated by sea-orm-macros
- `attempts`: Generated by sea-orm-macros
- `next_attempt_at`: Generated by sea-orm-macros
- `last_error`: Generated by sea-orm-macros
- `updated_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 {
    EditionId,
    Destination,
    State,
    StorageKey,
    Attempts,
    NextAttemptAt,
    LastError,
    UpdatedAt,
}
```

Generated by sea-orm-macros

**Variants**

- `EditionId`: Generated by sea-orm-macros
- `Destination`: Generated by sea-orm-macros
- `State`: Generated by sea-orm-macros
- `StorageKey`: Generated by sea-orm-macros
- `Attempts`: Generated by sea-orm-macros
- `NextAttemptAt`: Generated by sea-orm-macros
- `LastError`: Generated by sea-orm-macros
- `UpdatedAt`: Generated by sea-orm-macros

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

### PrimaryKey

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

Generated by sea-orm-macros

**Variants**

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

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

### Relation

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

Declared SeaORM relations (none unless FK edges are modeled).

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