Skip to content

Commit b9b8bc7

Browse files
server: Remove all Debug impl except necessary
Reduces a little bit binary size and they are not useful anyways given that it is a binary size and the user can't debug the types if something fails.
1 parent 622d75b commit b9b8bc7

12 files changed

Lines changed: 22 additions & 36 deletions

File tree

server/src/capability.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn set_bounding_set(caps: CapabilitySet) -> Result<(), rustix::io::Errno> {
5858
Ok(())
5959
}
6060

61-
#[derive(Debug, PartialEq)]
61+
#[derive(PartialEq)]
6262
enum CapabilityState {
6363
Full, // setuid root or root user
6464
Partial, // filesystem-based capabilities

server/src/collection/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::{
2424
item,
2525
};
2626

27-
#[derive(Debug, Clone)]
27+
#[derive(Clone)]
2828
pub struct Collection {
2929
// Properties
3030
items: Arc<Mutex<Vec<item::Item>>>,

server/src/gnome/internal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use crate::{
2020
pub const INTERNAL_INTERFACE_PATH: &str =
2121
"/org/gnome/keyring/InternalUnsupportedGuiltRiddenInterface";
2222

23-
#[derive(Debug, Clone)]
23+
#[derive(Clone)]
2424
pub struct InternalInterface {
2525
service: Service,
2626
}

server/src/gnome/prompter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ mod double_value_optional {
4343
}
4444
}
4545

46-
#[derive(Debug, Serialize, Deserialize, Type, Default)]
46+
#[derive(Serialize, Deserialize, Type, Default)]
4747
#[zvariant(signature = "dict")]
4848
#[serde(rename_all = "kebab-case")]
4949
// GcrPrompt properties <https://gitlab.gnome.org/GNOME/gcr/-/blob/main/gcr/gcr-prompt.c#L95>
@@ -226,7 +226,7 @@ impl TryFrom<String> for Reply {
226226
}
227227
}
228228

229-
#[derive(Deserialize, Serialize, Debug, Type, PartialEq, Eq, PartialOrd, Ord)]
229+
#[derive(Debug, Deserialize, Serialize, Type, PartialEq, Eq, PartialOrd, Ord)]
230230
#[serde(rename_all = "lowercase")]
231231
#[zvariant(signature = "s")]
232232
pub enum PromptType {
@@ -254,7 +254,7 @@ pub trait GNOMEPrompter {
254254
fn stop_prompting(&self, callback: &ObjectPath<'_>) -> Result<(), ServiceError>;
255255
}
256256

257-
#[derive(Debug, Clone)]
257+
#[derive(Clone)]
258258
pub struct GNOMEPrompterCallback {
259259
window_id: Option<WindowIdentifierType>,
260260
private_key: Arc<Key>,

server/src/item/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use zbus::zvariant::{ObjectPath, OwnedObjectPath};
88

99
use crate::{Service, collection::Collection, error::custom_service_error};
1010

11-
#[derive(Debug, Clone)]
11+
#[derive(Clone)]
1212
pub struct Item {
1313
// Properties
1414
pub(super) inner: Arc<Mutex<Option<oo7::file::Item>>>,

server/src/migration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use oo7::{Secret, file::UnlockedKeyring};
77
use crate::error::Error;
88

99
/// Pending keyring migration
10-
#[derive(Clone, Debug)]
10+
#[derive(Clone)]
1111
pub enum PendingMigration {
1212
/// Legacy v0 keyring format
1313
V0 {

server/src/pam_listener/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ enum PamOperation {
2525
ChangePassword = 1,
2626
}
2727

28-
#[derive(Debug, Serialize, Deserialize, Type, Zeroize, ZeroizeOnDrop)]
28+
#[derive(Serialize, Deserialize, Type, Zeroize, ZeroizeOnDrop)]
2929
struct PamMessage {
3030
#[zeroize(skip)]
3131
operation: PamOperation,

server/src/plasma/prompter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
};
2020

2121
#[repr(i32)]
22-
#[derive(Debug, Type, Serialize)]
22+
#[derive(Type, Serialize)]
2323
pub enum CallbackAction {
2424
Dismiss = 0,
2525
Keep = 1,
@@ -77,7 +77,7 @@ pub trait PlasmaPrompter {
7777
) -> Result<(), ServiceError>;
7878
}
7979

80-
#[derive(Debug, Clone)]
80+
#[derive(Clone)]
8181
pub struct PlasmaPrompterCallback {
8282
service: Service,
8383
prompt_path: OwnedObjectPath,

server/src/prompt/mod.rs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,19 +75,6 @@ pub struct Prompt {
7575
action: Arc<Mutex<Option<PromptAction>>>,
7676
}
7777

78-
// Manual impl because OnceCell doesn't impl Debug
79-
impl std::fmt::Debug for Prompt {
80-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
81-
f.debug_struct("Prompt")
82-
.field("service", &self.service)
83-
.field("role", &self.role)
84-
.field("path", &self.path)
85-
.field("label", &self.label)
86-
.field("collection", &self.collection)
87-
.finish()
88-
}
89-
}
90-
9178
#[cfg(any(
9279
feature = "gnome_openssl_crypto",
9380
feature = "gnome_native_crypto",
@@ -114,9 +101,9 @@ impl Prompt {
114101
PlasmaPrompterCallback::new(self.service.clone(), self.path.clone()).await;
115102
let path = OwnedObjectPath::from(callback.path().clone());
116103

117-
self.plasma_callback
118-
.set(callback.clone())
119-
.expect("A prompt callback is only set once");
104+
// We are sure the callback is not set at this point, so it is fine to ignore
105+
// the result of set
106+
let _ = self.plasma_callback.set(callback.clone());
120107
self.service
121108
.object_server()
122109
.at(&path, callback.clone())
@@ -147,10 +134,9 @@ impl Prompt {
147134

148135
let path = OwnedObjectPath::from(callback.path().clone());
149136

150-
self.gnome_callback
151-
.set(callback.clone())
152-
.expect("A prompt callback is only set once");
153-
137+
// We are sure the callback is not set at this point, so it is fine to ignore
138+
// the result of set
139+
let _ = self.gnome_callback.set(callback.clone());
154140
self.service.object_server().at(&path, callback).await?;
155141
tracing::debug!("Prompt `{}` created.", self.path);
156142

server/src/service/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,14 @@ const DEFAULT_COLLECTION_ALIAS_PATH: ObjectPath<'static> =
3838
ObjectPath::from_static_str_unchecked("/org/freedesktop/secrets/aliases/default");
3939

4040
/// Prompter type
41-
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
41+
#[derive(Clone, Copy, PartialEq, Eq)]
4242
pub enum PrompterType {
4343
#[allow(clippy::upper_case_acronyms)]
4444
GNOME,
4545
Plasma,
4646
}
4747

48-
#[derive(Debug, Clone)]
48+
#[derive(Clone)]
4949
pub struct Service {
5050
// Properties
5151
pub(crate) collections: Arc<Mutex<HashMap<OwnedObjectPath, Collection>>>,

0 commit comments

Comments
 (0)