get rid of unneded lifetime
This commit is contained in:
parent
959c9e91e9
commit
57e159d62e
|
@ -20,8 +20,8 @@ use tracing::{debug, error};
|
|||
use twitch_api2::{helix::users::GetUsersRequest, twitch_oauth2::AppAccessToken, HelixClient};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct App<'a> {
|
||||
pub helix_client: HelixClient<'a, reqwest::Client>,
|
||||
pub struct App {
|
||||
pub helix_client: HelixClient<'static, reqwest::Client>,
|
||||
pub token: Arc<AppAccessToken>,
|
||||
pub users: UsersCache,
|
||||
pub optout_codes: Arc<DashSet<String>>,
|
||||
|
@ -30,7 +30,7 @@ pub struct App<'a> {
|
|||
pub config: Arc<Config>,
|
||||
}
|
||||
|
||||
impl App<'_> {
|
||||
impl App {
|
||||
pub async fn get_users(
|
||||
&self,
|
||||
ids: Vec<String>,
|
||||
|
|
|
@ -35,7 +35,7 @@ const COMMAND_PREFIX: &str = "!rustlog ";
|
|||
|
||||
pub async fn run<C: LoginCredentials>(
|
||||
login_credentials: C,
|
||||
app: App<'static>,
|
||||
app: App,
|
||||
writer_tx: Sender<Message<'static>>,
|
||||
shutdown_rx: ShutdownRx,
|
||||
) {
|
||||
|
@ -44,12 +44,12 @@ pub async fn run<C: LoginCredentials>(
|
|||
}
|
||||
|
||||
struct Bot {
|
||||
app: App<'static>,
|
||||
app: App,
|
||||
writer_tx: Sender<Message<'static>>,
|
||||
}
|
||||
|
||||
impl Bot {
|
||||
pub fn new(app: App<'static>, writer_tx: Sender<Message<'static>>) -> Bot {
|
||||
pub fn new(app: App, writer_tx: Sender<Message<'static>>) -> Bot {
|
||||
Self { app, writer_tx }
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
|||
use std::time::Duration;
|
||||
use tracing::debug;
|
||||
|
||||
pub async fn get_channels(app: State<App<'_>>) -> Json<ChannelsList> {
|
||||
pub async fn get_channels(app: State<App>) -> Json<ChannelsList> {
|
||||
let channel_ids = app.config.channels.read().unwrap().clone();
|
||||
|
||||
let channels = app
|
||||
|
@ -45,7 +45,7 @@ pub async fn get_channels(app: State<App<'_>>) -> Json<ChannelsList> {
|
|||
}
|
||||
|
||||
pub async fn get_channel_logs(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
Path(channel_log_params): Path<ChannelLogsPath>,
|
||||
Query(logs_params): Query<LogsParams>,
|
||||
) -> Result<LogsResponse> {
|
||||
|
@ -78,7 +78,7 @@ pub async fn get_channel_logs(
|
|||
}
|
||||
|
||||
pub async fn get_user_logs_by_name(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
path: Path<UserLogsPath>,
|
||||
params: Query<LogsParams>,
|
||||
) -> Result<LogsResponse> {
|
||||
|
@ -94,7 +94,7 @@ pub async fn get_user_logs_by_name(
|
|||
}
|
||||
|
||||
pub async fn get_user_logs_by_id(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
path: Path<UserLogsPath>,
|
||||
params: Query<LogsParams>,
|
||||
) -> Result<LogsResponse> {
|
||||
|
@ -103,7 +103,7 @@ pub async fn get_user_logs_by_id(
|
|||
}
|
||||
|
||||
async fn get_user_logs(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
Path(user_logs_path): Path<UserLogsPath>,
|
||||
Query(logs_params): Query<LogsParams>,
|
||||
user_id: String,
|
||||
|
@ -143,7 +143,7 @@ async fn get_user_logs(
|
|||
|
||||
pub async fn list_available_logs(
|
||||
Query(AvailableLogsParams { user, channel }): Query<AvailableLogsParams>,
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
) -> Result<Json<AvailableLogs>> {
|
||||
let channel_id = match channel {
|
||||
ChannelParam::ChannelId(id) => id,
|
||||
|
@ -227,7 +227,7 @@ fn redirect_to_latest_user_logs(
|
|||
}
|
||||
|
||||
pub async fn random_channel_line(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
Path(LogsPathChannel {
|
||||
channel_id_type,
|
||||
channel,
|
||||
|
@ -249,7 +249,7 @@ pub async fn random_channel_line(
|
|||
}
|
||||
|
||||
pub async fn random_user_line_by_name(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
Path(UserLogPathParams {
|
||||
channel_id_type,
|
||||
channel,
|
||||
|
@ -262,7 +262,7 @@ pub async fn random_user_line_by_name(
|
|||
}
|
||||
|
||||
pub async fn random_user_line_by_id(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
Path(UserLogPathParams {
|
||||
channel_id_type,
|
||||
channel,
|
||||
|
@ -274,7 +274,7 @@ pub async fn random_user_line_by_id(
|
|||
}
|
||||
|
||||
async fn random_user_line(
|
||||
app: State<App<'_>>,
|
||||
app: State<App>,
|
||||
channel_id_type: ChannelIdType,
|
||||
channel: String,
|
||||
user_id: String,
|
||||
|
@ -294,7 +294,7 @@ async fn random_user_line(
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn optout(app: State<App<'_>>) -> Json<String> {
|
||||
pub async fn optout(app: State<App>) -> Json<String> {
|
||||
let mut rng = thread_rng();
|
||||
let optout_code: String = (0..5).map(|_| rng.sample(Alphanumeric) as char).collect();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ use std::{
|
|||
use tower_http::{cors::CorsLayer, normalize_path::NormalizePath, trace::TraceLayer};
|
||||
use tracing::{debug, info};
|
||||
|
||||
pub async fn run(app: App<'static>, mut shutdown_rx: ShutdownRx) {
|
||||
pub async fn run(app: App, mut shutdown_rx: ShutdownRx) {
|
||||
aide::gen::on_error(|error| {
|
||||
panic!("Could not generate docs: {error}");
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue