nyx_space/io/
watermark.rs1use std::collections::HashMap;
20
21use hifitime::Epoch;
22use parquet::{
23 basic::{Compression, ZstdLevel},
24 file::properties::WriterProperties,
25 format::KeyValue,
26};
27use shadow_rs::shadow;
28use whoami::{platform, realname, username};
29
30shadow!(build);
31
32pub(crate) fn pq_writer(metadata: Option<HashMap<String, String>>) -> Option<WriterProperties> {
34 let bldr = WriterProperties::builder()
35 .set_compression(Compression::ZSTD(ZstdLevel::try_new(10).unwrap()));
36
37 let mut file_metadata = vec![
38 KeyValue::new("Generated by".to_string(), prj_name_ver()),
39 KeyValue::new(
40 format!("{} License", build::PROJECT_NAME),
41 "AGPL 3.0".to_string(),
42 ),
43 KeyValue::new(
44 "Created by".to_string(),
45 format!("{} ({}) on {}", realname(), username(), platform()),
46 ),
47 KeyValue::new(
48 "Created on".to_string(),
49 format!("{}", Epoch::now().unwrap()),
50 ),
51 ];
52
53 if let Some(custom_md) = metadata {
54 for (k, v) in custom_md {
55 file_metadata.push(KeyValue::new(k, v));
56 }
57 }
58
59 Some(bldr.set_key_value_metadata(Some(file_metadata)).build())
60}
61
62pub(crate) fn prj_name_ver() -> String {
63 format!("Nyx Space v{}", build::PKG_VERSION)
64}