Skip to main content

rama_http/layer/har/recorder/
mod.rs

1use super::spec;
2use std::sync::Arc;
3
4mod fs;
5pub use fs::{FileRecorder, HarFilePath};
6use rama_core::extensions::Extensions;
7use rama_utils::str::arcstr::ArcStr;
8
9#[derive(Debug, Clone)]
10/// This object represents the root of exported data.
11pub struct LogMetaInfo {
12    /// Version number of the format. If empty, string "1.1" is assumed by default.
13    pub version: ArcStr,
14    /// Name and version info of the log creator application.
15    pub creator: spec::Creator,
16    /// Name and version info of used browser.
17    pub browser: Option<spec::Browser>,
18    /// A comment provided by the user or the application.
19    pub comment: Option<ArcStr>,
20}
21
22pub trait Recorder: Send + Sync + 'static {
23    fn record(&self, entry: spec::Log) -> impl Future<Output = Option<Extensions>> + Send + '_;
24
25    // this function will be called even when no session is active,
26    // a recorder has to handle this as a nop (ignore)
27    fn stop_record(&self) -> impl Future<Output = ()> + Send;
28}
29
30impl<R: Recorder> Recorder for Arc<R> {
31    fn record(&self, log: spec::Log) -> impl Future<Output = Option<Extensions>> + Send + '_ {
32        (**self).record(log)
33    }
34
35    fn stop_record(&self) -> impl Future<Output = ()> + Send {
36        (**self).stop_record()
37    }
38}