use super::SimilarSymbol;
use serde::{Deserialize, Serialize};
#[non_exhaustive]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Recommendation {
pub symbol: String,
pub recommendations: Vec<SimilarSymbol>,
}
impl Recommendation {
pub fn symbols(&self) -> Vec<&str> {
self.recommendations
.iter()
.map(|s| s.symbol.as_str())
.collect()
}
pub fn count(&self) -> usize {
self.recommendations.len()
}
}
#[cfg(feature = "dataframe")]
impl Recommendation {
pub fn to_dataframe(&self) -> ::polars::prelude::PolarsResult<::polars::prelude::DataFrame> {
SimilarSymbol::vec_to_dataframe(&self.recommendations)
}
}