Enum Facts

Source
pub enum Facts {
    Artist(ArtistFacts),
    Release(ReleaseFacts),
    Track(TrackFacts),
    Label(LabelFacts),
}
Expand description

What a source says, for one kind of entity.

An enum rather than a flat bag of (field, value) strings: the display, the query grammar and doctor all have to know what a field means, and a generic bag pushes that knowledge into string literals scattered through the program. crate::analysis::FileAnalysis made the same choice.

§The two variants are not the same size, on purpose

An artist carries twelve fields, one of them a paragraph; a release carries four. Clippy points out that a Facts is therefore as large as its larger variant, and the usual remedy is to box that one. It is the wrong remedy here: artist records are the majority of this layer, so boxing them puts a heap allocation and a pointer chase on the common path in order to shrink the rare one. The whole store is a few hundred rows of a few hundred bytes — under a hundred kilobytes — and it is read once at start-up.

Variants§

§

Artist(ArtistFacts)

About an artist.

§

Release(ReleaseFacts)

About a release.

§

Track(TrackFacts)

About one recorded performance, identified by its sound.

§

Label(LabelFacts)

About a record label, including attributed prose when available.

Implementations§

Source§

impl Facts

Source

pub fn kind(&self) -> EntityKind

The kind of entity these facts can describe.

This is what makes a record’s entity kind and its contents impossible to contradict each other: the kind is derived from the facts rather than stored beside them.

Source

pub fn is_empty(&self) -> bool

true when the source answered but said nothing at all.

Distinct from having no record: “asked, and it holds nothing about this” and “never asked” are two different states, and the whole layer exists to keep them apart.

Trait Implementations§

Source§

impl Clone for Facts

Source§

fn clone(&self) -> Facts

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Facts

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Facts

Source§

fn eq(&self, other: &Facts) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Facts

Source§

impl StructuralPartialEq for Facts

Auto Trait Implementations§

§

impl Freeze for Facts

§

impl RefUnwindSafe for Facts

§

impl Send for Facts

§

impl Sync for Facts

§

impl Unpin for Facts

§

impl UnwindSafe for Facts

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

§

fn into_sample(self) -> T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
§

impl<T, U> ToSample<U> for T
where U: FromSample<T>,

§

fn to_sample_(self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,