Debian Codegraph @

third_party/rust/authenticator/src/transport/stub/transaction.rs

raw
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 use crate::errors;
6 use crate::statecallback::StateCallback;
7 use crate::transport::device_selector::{
8 DeviceBuildParameters, DeviceSelector, DeviceSelectorEvent,
9 };
10 use std::path::PathBuf;
11 use std::sync::mpsc::Sender;
12
13 pub struct Transaction {}
14
15 impl Transaction {
16 pub fn new<F, T>(
17 timeout: u64,
18 callback: StateCallback<crate::Result<T>>,
19 _status: Sender<crate::StatusUpdate>,
20 new_device_cb: F,
21 ) -> crate::Result<Self>
22 where
23 F: Fn(
24 DeviceBuildParameters,
25 Sender<DeviceSelectorEvent>,
26 Sender<crate::StatusUpdate>,
27 &dyn Fn() -> bool,
28 ) + Sync
29 + Send
30 + 'static,
31 T: 'static,
32 {
33 // Just to silence "unused"-warnings
34 let mut device_selector = DeviceSelector::run();
35 let _ = DeviceSelectorEvent::DevicesAdded(vec![]);
36 let _ = DeviceSelectorEvent::DeviceRemoved(PathBuf::new());
37 let _ = device_selector.clone_sender();
38 device_selector.stop();
39
40 callback.call(Err(errors::AuthenticatorError::U2FToken(
41 errors::U2FTokenError::NotSupported,
42 )));
43
44 Err(errors::AuthenticatorError::U2FToken(
45 errors::U2FTokenError::NotSupported,
46 ))
47 }
48
49 pub fn cancel(&mut self) {
50 /* No-op. */
51 }
52 }