Skip to content

Commit ed7d6c8

Browse files
committed
Minor things
1 parent 18f33b0 commit ed7d6c8

File tree

8 files changed

+18
-44
lines changed

8 files changed

+18
-44
lines changed

mullvad-daemon/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1674,7 +1674,7 @@ where
16741674
// and not have to request the list from the API.
16751675
event_listener.notify_remove_device_event(RemoveDeviceEvent {
16761676
account_token,
1677-
new_devices,
1677+
new_device_list: new_devices,
16781678
});
16791679
});
16801680
Self::oneshot_send(

mullvad-daemon/src/management_interface.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use mullvad_types::{
1515
settings::Settings,
1616
states::{TargetState, TunnelState},
1717
version,
18-
wireguard::{RotationInterval, RotationIntervalError}, TryFromProto,
18+
wireguard::{RotationInterval, RotationIntervalError},
19+
TryFromProto,
1920
};
2021
use mullvad_types::{
2122
proto::{
@@ -592,7 +593,8 @@ impl ManagementService for ManagementServiceImpl {
592593

593594
async fn update_custom_list(&self, request: Request<types::CustomList>) -> ServiceResult<()> {
594595
log::debug!("update_custom_list");
595-
let custom_list = mullvad_types::custom_list::CustomList::try_from_proto(request.into_inner())?;
596+
let custom_list =
597+
mullvad_types::custom_list::CustomList::try_from_proto(request.into_inner())?;
596598
let (tx, rx) = oneshot::channel();
597599
self.send_command_to_daemon(DaemonCommand::UpdateCustomList(tx, custom_list))?;
598600
self.wait_for_result(rx)
@@ -1032,9 +1034,7 @@ impl EventListener for ManagementInterfaceEventBroadcaster {
10321034
fn notify_remove_device_event(&self, remove_event: mullvad_types::device::RemoveDeviceEvent) {
10331035
log::debug!("Broadcasting remove device event");
10341036
self.notify(types::DaemonEvent {
1035-
event: Some(daemon_event::Event::RemoveDevice(
1036-
types::RemoveDeviceEvent::from(remove_event),
1037-
)),
1037+
event: Some(daemon_event::Event::RemoveDevice(remove_event.into_proto())),
10381038
})
10391039
}
10401040

mullvad-types/src/custom_list.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::relay_constraints::GeographicLocationConstraint;
2+
use crate::{IntoProto, TryFromProto};
23
#[cfg(target_os = "android")]
34
use jnix::{
45
jni::objects::{AutoLocal, JObject, JString},
56
FromJava, IntoJava, JnixEnv,
67
};
7-
use crate::{IntoProto, TryFromProto};
88
use serde::{Deserialize, Serialize};
99
use std::{
1010
collections::BTreeSet,

mullvad-types/src/device.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ pub struct DeviceEvent {
125125

126126
/// Emitted when a device is removed using the `RemoveDevice` RPC.
127127
/// This is not sent by a normal logout or when it is revoked remotely.
128-
#[derive(Clone, Debug)]
128+
#[derive(Clone, Debug, IntoProto, TryFromProto)]
129129
#[cfg_attr(target_os = "android", derive(IntoJava))]
130130
#[cfg_attr(target_os = "android", jnix(package = "net.mullvad.mullvadvpn.model"))]
131131
pub struct RemoveDeviceEvent {
132132
pub account_token: AccountToken,
133-
pub new_devices: Vec<Device>,
133+
pub new_device_list: Vec<Device>,
134134
}

mullvad-types/src/proto/client.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ use crate::{
1212
settings::{DnsOptions, Settings},
1313
states::TunnelState,
1414
version::AppVersionInfo,
15-
wireguard::{PublicKey, QuantumResistantState, RotationInterval}, IntoProto,
15+
wireguard::{PublicKey, QuantumResistantState, RotationInterval},
16+
IntoProto,
1617
};
1718
use crate::{proto::types, TryFromProto};
1819
use futures::{Stream, StreamExt};

mullvad-types/src/proto/types/conversions/custom_list.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use std::collections::BTreeSet;
21
use crate::proto::types;
3-
use crate::{IntoProto, TryFromProto};
42
use crate::relay_constraints::GeographicLocationConstraint;
3+
use crate::{IntoProto, TryFromProto};
4+
use std::collections::BTreeSet;
55

66
impl IntoProto<types::CustomList> for crate::custom_list::CustomList {
77
fn into_proto(self) -> types::CustomList {
@@ -19,7 +19,9 @@ impl IntoProto<types::CustomList> for crate::custom_list::CustomList {
1919
}
2020

2121
impl TryFromProto<types::CustomList> for crate::custom_list::CustomList {
22-
fn try_from_proto(other: types::CustomList) -> Result<Self, crate::proto::types::FromProtobufTypeError> {
22+
fn try_from_proto(
23+
other: types::CustomList,
24+
) -> Result<Self, crate::proto::types::FromProtobufTypeError> {
2325
let locations = other
2426
.locations
2527
.into_iter()

mullvad-types/src/proto/types/conversions/device.rs

+1-30
Original file line numberDiff line numberDiff line change
@@ -106,35 +106,6 @@ impl From<types::device_event::Cause> for crate::device::DeviceEventCause {
106106
}
107107
}
108108

109-
impl From<crate::device::RemoveDeviceEvent> for types::RemoveDeviceEvent {
110-
fn from(event: crate::device::RemoveDeviceEvent) -> Self {
111-
types::RemoveDeviceEvent {
112-
account_token: event.account_token,
113-
new_device_list: event
114-
.new_devices
115-
.into_iter()
116-
.map(|device| device.into_proto())
117-
.collect(),
118-
}
119-
}
120-
}
121-
122-
impl TryFrom<types::RemoveDeviceEvent> for crate::device::RemoveDeviceEvent {
123-
type Error = FromProtobufTypeError;
124-
125-
fn try_from(event: types::RemoveDeviceEvent) -> Result<Self, Self::Error> {
126-
let new_devices = event
127-
.new_device_list
128-
.into_iter()
129-
.map(crate::device::Device::try_from)
130-
.collect::<Result<Vec<_>, FromProtobufTypeError>>()?;
131-
Ok(crate::device::RemoveDeviceEvent {
132-
account_token: event.account_token,
133-
new_devices,
134-
})
135-
}
136-
}
137-
138109
impl From<crate::device::AccountAndDevice> for types::AccountAndDevice {
139110
fn from(device: crate::device::AccountAndDevice) -> Self {
140111
types::AccountAndDevice {
@@ -147,7 +118,7 @@ impl From<crate::device::AccountAndDevice> for types::AccountAndDevice {
147118
impl From<Vec<crate::device::Device>> for types::DeviceList {
148119
fn from(devices: Vec<crate::device::Device>) -> Self {
149120
types::DeviceList {
150-
devices: devices.into_iter().map(|dev| dev.into_proto()).collect(),
121+
devices: devices.into_proto(),
151122
}
152123
}
153124
}

mullvad-types/src/proto/types/conversions/settings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::proto::types::{self, FromProtobufTypeError};
2-
use crate::IntoProto;
32
use crate::settings::CURRENT_SETTINGS_VERSION;
3+
use crate::IntoProto;
44
use talpid_types::ErrorExt;
55

66
impl From<&crate::settings::Settings> for types::Settings {

0 commit comments

Comments
 (0)