reduct_rs/record/
remove_record.rs1use crate::http_client::HttpClient;
7use crate::record::from_system_time;
8use http::Method;
9use reduct_base::error::ReductError;
10use std::sync::Arc;
11
12pub struct RemoveRecordBuilder {
14 bucket: String,
15 entry: String,
16 timestamp: Option<u64>,
17 client: Arc<HttpClient>,
18}
19
20impl RemoveRecordBuilder {
21 pub(crate) fn new(bucket: String, entry: String, client: Arc<HttpClient>) -> Self {
22 Self {
23 bucket,
24 entry,
25 timestamp: None,
26 client,
27 }
28 }
29
30 pub fn timestamp_us(mut self, timestamp: u64) -> Self {
32 self.timestamp = Some(timestamp);
33 self
34 }
35
36 pub fn timestamp(mut self, timestamp: std::time::SystemTime) -> Self {
38 self.timestamp = Some(from_system_time(timestamp));
39 self
40 }
41
42 pub async fn send(self) -> Result<(), ReductError> {
52 let request = self.client.request(
53 Method::DELETE,
54 &format!(
55 "/b/{}/{}?ts={}",
56 self.bucket,
57 self.entry,
58 self.timestamp.expect("timestamp is required")
59 ),
60 );
61 self.client.send_request(request).await?;
62 Ok(())
63 }
64}