1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use open62541_sys::UA_SessionStatistics;
#[derive(Debug)]
#[repr(transparent)]
pub struct SessionStatistics(UA_SessionStatistics);
impl SessionStatistics {
/// Creates wrapper reference from value.
#[must_use]
pub(crate) const fn raw_ref(src: &UA_SessionStatistics) -> &Self {
let src: *const UA_SessionStatistics = src;
// This transmutes between the inner type and `Self` through `cast()`. This is okay because
// we are using `#[repr(transparent)]`.
let ptr = src.cast::<Self>();
// SAFETY: Pointer is valid and allowed to reference `Self` due to `#[repr(transparent)]`.
let ptr = unsafe { ptr.as_ref() };
// SAFETY: Pointer is valid (non-zero) because it comes from a reference.
unsafe { ptr.unwrap_unchecked() }
}
#[must_use]
pub const fn current_session_count(&self) -> usize {
self.0.currentSessionCount
}
#[must_use]
pub const fn cumulated_session_count(&self) -> usize {
self.0.cumulatedSessionCount
}
#[must_use]
pub const fn security_rejected_session_count(&self) -> usize {
self.0.securityRejectedSessionCount
}
#[must_use]
pub const fn rejected_session_count(&self) -> usize {
self.0.rejectedSessionCount
}
#[must_use]
pub const fn session_timeout_count(&self) -> usize {
self.0.sessionTimeoutCount
}
#[must_use]
pub const fn session_abort_count(&self) -> usize {
self.0.sessionAbortCount
}
}