Spaces:
Runtime error
Runtime error
Download src/services/keyframes/mod.rs from variphx/aic-server: direct link, hf CLI and curl.
- Browser
- Download file 812 Bytes
-
https://huggingface.co/spaces/variphx/aic-server/resolve/main/src/services/keyframes/mod.rs
- Command line
-
hf download hf://spaces/variphx/aic-server/src/services/keyframes/mod.rs
-
curl -L -o mod.rs https://huggingface.co/spaces/variphx/aic-server/resolve/main/src/services/keyframes/mod.rs
812 Bytes
| use deadpool_diesel::postgres::Pool; | |
| use crate::{ | |
| models::{dtos::keyframes::KeyframeDto, states::AppState}, | |
| repositories::keyframes::KeyframeRepository, | |
| }; | |
| pub struct KeyframeService<'a> { | |
| pool: &'a Pool, | |
| } | |
| impl<'a> From<&'a AppState> for KeyframeService<'a> { | |
| fn from(value: &'a AppState) -> Self { | |
| Self { | |
| pool: value.diesel_pool(), | |
| } | |
| } | |
| } | |
| impl<'a> KeyframeService<'a> { | |
| pub const fn pool(&self) -> &'a Pool { | |
| self.pool | |
| } | |
| } | |
| impl<'a> KeyframeService<'a> { | |
| pub async fn find_by_id(&self, id: i64) -> anyhow::Result<Option<KeyframeDto>> { | |
| let repository = KeyframeRepository::from(self); | |
| Ok(repository | |
| .find_by_id_and_join_video(id) | |
| .await? | |
| .map(Into::into)) | |
| } | |
| } | |