Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{
2 fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#,
3 iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#, Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#},
4 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#,
5 osrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/::{
6 fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/::AsRawFdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/AsRawFd#,
7 rawrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/::{c_uintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_uint#, c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong#},
8 },
9 pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#,
10 };
11
12 pub mod ppsrust-analyzer cargo pps-time 0.2.3 pps/;
13 use ppsrust-analyzer cargo pps-time 0.2.3 pps/::{pps_fdatarust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#, pps_kparamsrust-analyzer cargo pps-time 0.2.3 pps/pps_kparams#, pps_ktimerust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#, PPS_TIME_INVALIDrust-analyzer cargo pps-time 0.2.3 pps/PPS_TIME_INVALID.};
14
15 // These constants rely on macros which bindgen does not export from pps.h
16 const PPS_GETPARAMSrust-analyzer cargo pps-time 0.2.3 PPS_GETPARAMS.: c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong# = 0x800870a1;
17 const PPS_SETPARAMSrust-analyzer cargo pps-time 0.2.3 PPS_SETPARAMS.: c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong# = 0x400870a2;
18 const PPS_GETCAPrust-analyzer cargo pps-time 0.2.3 PPS_GETCAP.: c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong# = 0x800870a3;
19 const PPS_FETCHrust-analyzer cargo pps-time 0.2.3 PPS_FETCH.: c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong# = 0xc00870a4;
20
21 pub struct PpsDevicerust-analyzer cargo pps-time 0.2.3 PpsDevice#(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#);
22
23 impl PpsDevicerust-analyzer cargo pps-time 0.2.3 PpsDevice# {
24 pub fn newrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]new().(path: PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<PpsDevicerust-analyzer cargo pps-time 0.2.3 PpsDevice#> {
25 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(PpsDevicerust-analyzer cargo pps-time 0.2.3 PpsDevice#(Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#::openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[File]open().(path)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))
26 }
27
28 /// Perform ioctl request and check result for possible errors
29 unsafe fn ioctlrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl().<T>(&self, request: c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong#, value: &mut T) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
30 match libcrust-analyzer cargo libc 0.2.168 crate/::ioctlrust-analyzer cargo libc 0.2.168 ioctl().(self.0rust-analyzer cargo pps-time 0.2.3 PpsDevice#0..as_raw_fdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/fd/raw/impl#[`fs::File`][AsRawFd]as_raw_fd().(), request as _, value) {
31 0 => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()),
32 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().()),
33 }
34 }
35
36 /// Perform ioctl request with uninitialized memory
37 unsafe fn ioctl_uninitrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl_uninit().<T>(&self, request: c_ulongrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_ulong#) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<T> {
38 let mut value: MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#<T> = MaybeUninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/MaybeUninit#::uninitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]uninit().();
39 self.ioctlrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl().(request, &mut value)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
40 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(unsafe { value.assume_initrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/maybe_uninit/impl#[`MaybeUninit<T>`]assume_init().() })
41 }
42
43 pub fn get_paramsrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]get_params().(&self) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<pps_kparamsrust-analyzer cargo pps-time 0.2.3 pps/pps_kparams#> {
44 // Safety: PPS_GETPARAMS writes pps_kparams, for which memory is allocated and returned by ioctl_uninit
45 unsafe { self.ioctl_uninitrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl_uninit().(PPS_GETPARAMSrust-analyzer cargo pps-time 0.2.3 PPS_GETPARAMS.) }
46 }
47
48 pub fn set_paramsrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]set_params().(&self, params: &mut pps_kparamsrust-analyzer cargo pps-time 0.2.3 pps/pps_kparams#) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<()> {
49 // Safety: PPS_SETPARAMS expects pps_kparams, which lives for the duration of the call
50 unsafe { self.ioctlrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl().(PPS_SETPARAMSrust-analyzer cargo pps-time 0.2.3 PPS_SETPARAMS., params) }
51 }
52
53 pub fn get_caprust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]get_cap().(&self) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<c_uintrust-analyzer cargo std https://github.com/rust-lang/rust/library/std os/raw/c_uint#> {
54 // Safety: PPS_GETCAP writes a c_uint, for which memory is allocated and returned by ioctl_uninit
55 unsafe { self.ioctl_uninitrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl_uninit().(PPS_GETCAPrust-analyzer cargo pps-time 0.2.3 PPS_GETCAP.) }
56 }
57
58 fn fetchrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch().(&self, timeout: pps_ktimerust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<pps_fdatarust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#> {
59 let mut data = pps_fdatarust-analyzer cargo pps-time 0.2.3 pps/pps_fdata# {
60 inforust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#info.: Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo pps-time 0.2.3 pps/impl#[pps_kinfo][Default]default().(),
61 timeoutrust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#timeout.,
62 };
63
64 // Safety: PPS_FETCH expects and writes to a pps_fdata, which lives for the duration of the call
65 unsafe { self.ioctlrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]ioctl().(PPS_FETCHrust-analyzer cargo pps-time 0.2.3 PPS_FETCH., &mut data)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). };
66
67 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(data)
68 }
69
70 /// Fetch next PPS event, blocking until it arrives
71 ///
72 /// Device must support PPS_CANWAIT, otherwise it will give an EOPNOTSUPP error
73 pub fn fetch_blockingrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch_blocking().(&self) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<pps_fdatarust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#> {
74 self.fetchrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch().(pps_ktimerust-analyzer cargo pps-time 0.2.3 pps/pps_ktime# {
75 secrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#sec.: 0,
76 nsecrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#nsec.: 0,
77 flagsrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#flags.: PPS_TIME_INVALIDrust-analyzer cargo pps-time 0.2.3 pps/PPS_TIME_INVALID.,
78 })
79 }
80
81 /// Fetch next PPS event with a timeout, giving an ETIMEDOUT error if event does not come in time
82 ///
83 /// Device must support PPS_CANWAIT, otherwise it will give an EOPNOTSUPP error
84 pub fn fetch_timeoutrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch_timeout().(&self, seconds: i64, nanoseconds: i32) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<pps_fdatarust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#> {
85 self.fetchrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch().(pps_ktimerust-analyzer cargo pps-time 0.2.3 pps/pps_ktime# {
86 secrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#sec.: seconds,
87 nsecrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#nsec.: nanoseconds,
88 flagsrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#flags.: 0,
89 })
90 }
91
92 /// Fetch newest PPS event without blocking
93 pub fn fetch_non_blockingrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch_non_blocking().(&self) -> Resultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Result#<pps_fdatarust-analyzer cargo pps-time 0.2.3 pps/pps_fdata#> {
94 self.fetchrust-analyzer cargo pps-time 0.2.3 impl#[PpsDevice]fetch().(pps_ktimerust-analyzer cargo pps-time 0.2.3 pps/pps_ktime# {
95 secrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#sec.: 0,
96 nsecrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#nsec.: 0,
97 flagsrust-analyzer cargo pps-time 0.2.3 pps/pps_ktime#flags.: 0,
98 })
99 }
100 }