use std::future::Future;
use std::time::Duration;

use crate::error::AppError;

use super::types::PendingGrant;

pub trait CodeStore: Send + Sync + 'static {
    fn put(
        &self,
        code: String,
        grant: PendingGrant,
        ttl: Duration,
    ) -> impl Future<Output = Result<(), AppError>> + Send;

    fn take(
        &self,
        code: &str,
    ) -> impl Future<Output = Result<Option<PendingGrant>, AppError>> + Send;
}
