endpoint_sec/event/
event_od_attribute_set.rs1use std::ffi::OsStr;
4
5use endpoint_sec_sys::{es_event_od_attribute_set_t, es_od_record_type_t, es_string_token_t};
6
7use crate::Process;
8
9#[doc(alias = "es_event_od_attribute_set_t")]
17pub struct EventOdAttributeSet<'a> {
18 pub(crate) raw: &'a es_event_od_attribute_set_t,
20 pub(crate) version: u32,
22}
23
24impl<'a> EventOdAttributeSet<'a> {
25 #[inline(always)]
27 pub fn instigator(&self) -> Process<'a> {
28 Process::new(unsafe { self.raw.instigator.as_ref() }, self.version)
30 }
31
32 #[inline(always)]
34 pub fn error_code(&self) -> i32 {
35 self.raw.error_code
36 }
37
38 #[inline(always)]
40 pub fn record_type(&self) -> es_od_record_type_t {
41 self.raw.record_type
42 }
43
44 #[inline(always)]
46 pub fn record_name(&self) -> &'a OsStr {
47 unsafe { self.raw.record_name.as_os_str() }
49 }
50
51 #[inline(always)]
53 pub fn attribute_name(&self) -> &'a OsStr {
54 unsafe { self.raw.attribute_name.as_os_str() }
56 }
57
58 #[inline(always)]
60 pub fn attribute_value_count(&self) -> usize {
61 self.raw.attribute_value_count
62 }
63
64 #[inline(always)]
66 pub fn attribute_values<'s>(&'s self) -> AttributeValues<'s, 'a> {
67 AttributeValues::new(self)
68 }
69
70 #[inline(always)]
74 pub fn node_name(&self) -> &'a OsStr {
75 unsafe { self.raw.node_name.as_os_str() }
77 }
78
79 #[inline(always)]
82 pub fn db_path(&self) -> Option<&'a OsStr> {
83 if self.node_name() == OsStr::new("/Local/Default") {
84 Some(unsafe { self.raw.db_path.as_os_str() })
86 } else {
87 None
88 }
89 }
90}
91
92unsafe impl Send for EventOdAttributeSet<'_> {}
94unsafe impl Sync for EventOdAttributeSet<'_> {}
96
97impl_debug_eq_hash_with_functions!(EventOdAttributeSet<'a> with version; instigator, error_code, record_type, record_name, attribute_name, attribute_value_count, node_name, db_path);
98
99unsafe fn read_nth_attribute_value(raw: &es_event_od_attribute_set_t, idx: usize) -> es_string_token_t {
105 std::ptr::read(raw.attribute_value_array.add(idx))
106}
107
108make_event_data_iterator!(
109 EventOdAttributeSet;
110 AttributeValues with attribute_value_count (usize);
112 &'raw OsStr;
113 read_nth_attribute_value,
114 super::as_os_str,
115);