Struct pikadick::commands::reddit_embed::RedditEmbedData
source · pub struct RedditEmbedData {
reddit_client: Client,
reddit_tube_client: Client,
pub cache: TimedCache<(String, String), String>,
pub video_data_cache: TimedCache<String, Box<GetVideoResponseOk>>,
random_post_cache: Arc<DashMap<String, Arc<(Instant, Vec<Arc<Link>>)>>>,
}
Fields§
§reddit_client: Client
§reddit_tube_client: Client
§cache: TimedCache<(String, String), String>
§video_data_cache: TimedCache<String, Box<GetVideoResponseOk>>
§random_post_cache: Arc<DashMap<String, Arc<(Instant, Vec<Arc<Link>>)>>>
Implementations§
source§impl RedditEmbedData
impl RedditEmbedData
sourcepub fn new() -> Self
pub fn new() -> Self
Make a new RedditEmbedData
.
sourcepub async fn get_original_post(
&self,
subreddit: &str,
post_id: &str
) -> Result<Box<Link>>
pub async fn get_original_post( &self, subreddit: &str, post_id: &str ) -> Result<Box<Link>>
Get the original post from a given subreddit and post id.
This resolves crossposts. Currently only resolves 1 layer.
sourcepub async fn get_video_data(&self, url: &str) -> Result<Box<GetVideoResponseOk>>
pub async fn get_video_data(&self, url: &str) -> Result<Box<GetVideoResponseOk>>
Get video data from reddit.tube.
Takes a reddit url.
sourcepub async fn get_video_data_cached(
&self,
url: &str
) -> Result<Arc<TimedCacheEntry<Box<GetVideoResponseOk>>>>
pub async fn get_video_data_cached( &self, url: &str ) -> Result<Arc<TimedCacheEntry<Box<GetVideoResponseOk>>>>
Get video data, but using a cache.
sourcepub async fn create_video_url(&self, url: &str) -> Result<Url>
pub async fn create_video_url(&self, url: &str) -> Result<Url>
Create a video url for a url to a reddit video post.
sourcepub async fn get_embed_url(&self, url: &Url) -> Result<String>
pub async fn get_embed_url(&self, url: &Url) -> Result<String>
Get a reddit embed url for a given subreddit and post id
sourcepub async fn try_embed_url(
&self,
ctx: &Context,
msg: &Message,
url: &Url,
loading_reaction: &mut Option<LoadingReaction>
) -> Result<()>
pub async fn try_embed_url( &self, ctx: &Context, msg: &Message, url: &Url, loading_reaction: &mut Option<LoadingReaction> ) -> Result<()>
Try to embed a url
sourcepub async fn get_random_post(&self, subreddit: &str) -> Result<Option<String>>
pub async fn get_random_post(&self, subreddit: &str) -> Result<Option<String>>
Get a random post url for a subreddit
sourceasync fn reddit_link_to_embed_url(&self, link: &Link) -> Result<String>
async fn reddit_link_to_embed_url(&self, link: &Link) -> Result<String>
Convert a reddit link to an embed url
Trait Implementations§
source§impl CacheStatsProvider for RedditEmbedData
impl CacheStatsProvider for RedditEmbedData
source§fn publish_cache_stats(&self, cache_stats_builder: &mut CacheStatsBuilder)
fn publish_cache_stats(&self, cache_stats_builder: &mut CacheStatsBuilder)
Publish stats to the provided
CacheStatsBuilder
.source§impl Clone for RedditEmbedData
impl Clone for RedditEmbedData
source§fn clone(&self) -> RedditEmbedData
fn clone(&self) -> RedditEmbedData
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RedditEmbedData
impl Debug for RedditEmbedData
Auto Trait Implementations§
impl !RefUnwindSafe for RedditEmbedData
impl Send for RedditEmbedData
impl Sync for RedditEmbedData
impl Unpin for RedditEmbedData
impl !UnwindSafe for RedditEmbedData
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
Mutably borrows from an owned value. Read more
§impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
§impl<T> CloneableStorage for Twhere
T: Any + Send + Sync + Clone,
impl<T> CloneableStorage for Twhere T: Any + Send + Sync + Clone,
fn clone_storage(&self) -> Box<dyn CloneableStorage>
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request