Struct database::media::Media

source ·
pub struct Media {
    pub id: i64,
    pub library_id: i64,
    pub name: String,
    pub description: Option<String>,
    pub rating: Option<f64>,
    pub year: Option<i64>,
    pub added: Option<String>,
    pub poster_path: Option<String>,
    pub backdrop_path: Option<String>,
    pub media_type: MediaType,
}
Expand description

Media struct that represents a media object, usually a movie, tv show or a episode of a tv show. This struct is returned by several methods and can be serialized to json.

Fields§

§id: i64

unique id.

§library_id: i64

id of the library that this media objects belongs to.

§name: String

name of this media object. Usually the title of a movie, episode or tv show.

§description: Option<String>

description of this media object. Usually overview of a movie etc.

§rating: Option<f64>

rating provided by any API that is encoded as a signed integer. Usually TMDB rating.

§year: Option<i64>

Year in which this movie/tv show/episode was released/aired.

§added: Option<String>

Date when this media object was created and inserted into the database. Used by several routes to return sorted lists of medias, based on when they were scanned and inserted into the db.

§poster_path: Option<String>

Path to the media poster.

§backdrop_path: Option<String>

Path to the backdrop for this media object.

§media_type: MediaType

Media type encoded as a string. Either movie/tv/episode or none.

Implementations§

Method returns all Media objects associated with a Library. Its exactly the same as Library::get except it takes in a Library object instead of a id. Library::get is a intermediary to this function, as it calls this function.

Arguments
  • conn - mutable reference to a sqlx transaction.
  • library_id - a Library id.

Method returns a media object based on its id

Arguments
  • conn - mutable reference to a sqlx transaction.
  • req_id - id of a media that we’d like to match against.

Method to get a entry in a library based on name and library

Arguments
  • conn - mutable reference to a sqlx transaction.
  • library_id - a library id.
  • name - string slice reference containing the name we would like to filter by.

Method returns the top rated medias

Method returns the recently added medias

Method deletes a media object based on its id.

Arguments
  • conn - mutable reference to a sqlx transaction.
  • id - id of a media object we want to delete

This function exists because for some reason CASCADE DELETE doesnt work with a sqlite backend. Thus we must manually delete entries when deleting a library.

Get compact representation of a media object. This returns the library_id and media_type of the media object.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Converts this type into the (usually inferred) input type.
Converts this type into the (usually inferred) input type.
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more