pub struct Analysis {
pub id: AnalysisId,
pub features: [f64; 20],
}Expand description
Fields§
§id: AnalysisIdthe unique identifier for this Analysis.
features: [f64; 20]The [Song]’s audio features.
Implementations§
Source§impl Analysis
impl Analysis
Sourcepub async fn create<C: Connection>(
db: &Surreal<C>,
song_id: SongId,
analysis: Self,
) -> StorageResult<Option<Self>>
pub async fn create<C: Connection>( db: &Surreal<C>, song_id: SongId, analysis: Self, ) -> StorageResult<Option<Self>>
create a new analysis for the given song
If an analysis already exists for the song, this will return None.
pub async fn read<C: Connection>( db: &Surreal<C>, id: AnalysisId, ) -> StorageResult<Option<Self>>
pub async fn read_all<C: Connection>( db: &Surreal<C>, ) -> StorageResult<Vec<Self>>
Sourcepub async fn read_for_song<C: Connection>(
db: &Surreal<C>,
song_id: SongId,
) -> StorageResult<Option<Self>>
pub async fn read_for_song<C: Connection>( db: &Surreal<C>, song_id: SongId, ) -> StorageResult<Option<Self>>
Read the analysis for a song
If the song does not have an analysis, this will return None.
Sourcepub async fn read_for_songs<C: Connection>(
db: &Surreal<C>,
song_ids: Vec<SongId>,
) -> StorageResult<Vec<Option<Self>>>
pub async fn read_for_songs<C: Connection>( db: &Surreal<C>, song_ids: Vec<SongId>, ) -> StorageResult<Vec<Option<Self>>>
Read the analysis for OneOrMany song(s)
Needed for clustering(?)
We return a Vec<Option
Sourcepub async fn read_song<C: Connection>(
db: &Surreal<C>,
id: AnalysisId,
) -> StorageResult<Song>
pub async fn read_song<C: Connection>( db: &Surreal<C>, id: AnalysisId, ) -> StorageResult<Song>
Read the song for an analysis
Sourcepub async fn read_songs<C: Connection>(
db: &Surreal<C>,
ids: OneOrMany<AnalysisId>,
) -> StorageResult<OneOrMany<Song>>
pub async fn read_songs<C: Connection>( db: &Surreal<C>, ids: OneOrMany<AnalysisId>, ) -> StorageResult<OneOrMany<Song>>
Read the song for OneOrMany analyses
needed to convert a list of analyses (such as what we get from nearest_neighbors) into a list of songs
Sourcepub async fn read_songs_without_analysis<C: Connection>(
db: &Surreal<C>,
) -> StorageResult<Vec<Song>>
pub async fn read_songs_without_analysis<C: Connection>( db: &Surreal<C>, ) -> StorageResult<Vec<Song>>
Get all the songs that don’t have an analysis
Sourcepub async fn delete<C: Connection>(
db: &Surreal<C>,
id: AnalysisId,
) -> StorageResult<Option<Self>>
pub async fn delete<C: Connection>( db: &Surreal<C>, id: AnalysisId, ) -> StorageResult<Option<Self>>
Delete an analysis
Sourcepub async fn nearest_neighbors<C: Connection>(
db: &Surreal<C>,
id: AnalysisId,
n: u32,
) -> StorageResult<Vec<Self>>
pub async fn nearest_neighbors<C: Connection>( db: &Surreal<C>, id: AnalysisId, n: u32, ) -> StorageResult<Vec<Self>>
Find the n nearest neighbors to an analysis
Sourcepub async fn nearest_neighbors_to_many<C: Connection>(
db: &Surreal<C>,
ids: Vec<AnalysisId>,
n: u32,
) -> StorageResult<Vec<Self>>
pub async fn nearest_neighbors_to_many<C: Connection>( db: &Surreal<C>, ids: Vec<AnalysisId>, n: u32, ) -> StorageResult<Vec<Self>>
Find the n nearest neighbors to a list of analyses
The provided analyses should not be included in the results
Source§impl Analysis
impl Analysis
pub fn generate_id() -> AnalysisId
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Analysis
impl<'de> Deserialize<'de> for Analysis
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Table for Analysis
impl Table for Analysis
const TABLE_NAME: &'static str = "analysis"
fn init_table<C: Connection>( db: &Surreal<C>, ) -> impl Future<Output = Result<()>> + Send
impl StructuralPartialEq for Analysis
Auto Trait Implementations§
impl Freeze for Analysis
impl RefUnwindSafe for Analysis
impl Send for Analysis
impl Sync for Analysis
impl Unpin for Analysis
impl UnwindSafe for Analysis
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.