jvmti_rs/wrapper/objects/
jtimer_info.rs1use crate::sys::{jlong, jvmtiTimerInfo, jvmtiTimerKind, jboolean};
2use crate::{JvmtiTimerKind, to_bool};
3use std::marker::PhantomData;
4
5#[derive(Debug)]
6pub struct JTimerInfo<'a> {
7 internal: jvmtiTimerInfo,
8 lifetime: PhantomData<&'a ()>,
9
10 pub max_value: jlong,
11 pub may_skip_forward: bool,
12 pub may_skip_backward: bool,
13 pub kind: JvmtiTimerKind,
14 pub reserved1: jlong,
15 pub reserved2: jlong,
16}
17
18impl<'a> JTimerInfo<'a> {
19 pub fn empty_raw() -> jvmtiTimerInfo {
20 jvmtiTimerInfo {
21 max_value: 0 as jlong,
22 may_skip_forward: 0 as jboolean,
23 may_skip_backward: 0 as jboolean,
24 kind: 0 as jvmtiTimerKind,
25 reserved1: 0 as jlong,
26 reserved2: 0 as jlong,
27 }
28 }
29}
30
31impl<'a> From<jvmtiTimerInfo> for JTimerInfo<'a> {
32 fn from(info: jvmtiTimerInfo) -> Self {
33 JTimerInfo {
34 internal: info,
35 lifetime: PhantomData,
36
37 max_value: info.max_value,
38 may_skip_forward: to_bool(info.may_skip_forward),
39 may_skip_backward: to_bool(info.may_skip_backward),
40 kind: info.kind.into(),
41 reserved1: info.reserved1,
42 reserved2: info.reserved2,
43 }
44 }
45}
46
47impl<'a> ::std::ops::Deref for JTimerInfo<'a> {
48 type Target = jvmtiTimerInfo;
49
50 fn deref(&self) -> &Self::Target {
51 &self.internal
52 }
53}