use std::marker::PhantomData;
use bon::bon;
use crate::webhooks::Webhook;
pub struct RocketWebhook<W, M = W>
where
W: Webhook,
{
pub(crate) webhook: W,
pub(crate) max_body_size: u32,
pub(crate) timestamp_tolerance: (u32, u32),
marker: PhantomData<M>,
}
#[bon]
impl<W> RocketWebhook<W, W>
where
W: Webhook,
{
#[builder]
pub fn new(
webhook: W,
#[builder(default = 64 * 1024)]
max_body_size: u32,
#[builder(default = (5 * 60, 15), with = |past_secs: u32, future_secs: u32| (past_secs, future_secs))]
timestamp_tolerance: (u32, u32),
) -> RocketWebhook<W, W> {
RocketWebhook {
webhook,
max_body_size,
timestamp_tolerance,
marker: PhantomData::<W>,
}
}
}
#[bon]
impl<W, M> RocketWebhook<W, M>
where
W: Webhook,
{
#[builder(start_fn(name = builder_with_marker, vis = "pub"), finish_fn = build, builder_type(vis = "pub"))]
fn with_marker(
webhook: W,
#[builder(with = |marker: M| PhantomData)]
marker: PhantomData<M>,
#[builder(default = 64 * 1024)]
max_body_size: u32,
#[builder(default = (5 * 60, 15), with = |past_secs: u32, future_secs: u32| (past_secs, future_secs))]
timestamp_tolerance: (u32, u32),
) -> RocketWebhook<W, M> {
RocketWebhook {
webhook,
marker,
max_body_size,
timestamp_tolerance,
}
}
}