1 // Copyright 2023 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 pub mod remote_auth_service;
16 
17 /// Struct representing the remote device.
18 pub struct RemoteDevice {
19     pub id: i32,
20 }
21 
22 /// Trait to be implemented by anything that wants to be notified when remote devices are discovered
23 /// or lost.
24 pub trait DeviceDiscoveryListener {
on_discovered(&mut self, remote_device: &RemoteDevice)25     fn on_discovered(&mut self, remote_device: &RemoteDevice);
on_lost(&mut self, remote_device: &RemoteDevice)26     fn on_lost(&mut self, remote_device: &RemoteDevice);
on_timeout(&mut self)27     fn on_timeout(&mut self);
28 }
29 
30 /// Trait to be implemented by the struct responsible for scanning for remote devices.
31 pub trait DiscoveryPublisher<'a, T: DeviceDiscoveryListener> {
32     /// Add a listener to the list and return a handle to that listener so it can be removed later.
add_listener(&mut self, listener: &'a mut T) -> i3233     fn add_listener(&mut self, listener: &'a mut T) -> i32;
34     /// Remove the listener with the given handle.
remove_listener(&mut self, listener_handle: i32)35     fn remove_listener(&mut self, listener_handle: i32);
36     /// Notify all listeners that a remote device has been discovered.
device_discovered(&mut self, remote_device: &RemoteDevice)37     fn device_discovered(&mut self, remote_device: &RemoteDevice);
38     /// Notify all listeners that a previously discovered remote device has been lost.
device_lost(&mut self, remote_device: &RemoteDevice)39     fn device_lost(&mut self, remote_device: &RemoteDevice);
40     /// Notify all listeners that timeout has occurred.
timed_out(&mut self)41     fn timed_out(&mut self);
42 }
43