Skip to content

Commit abc391c

Browse files
refactor: add partial_pub_fields clippy style and readability lint (#976)
1 parent bbdecc2 commit abc391c

File tree

29 files changed

+150
-70
lines changed

29 files changed

+150
-70
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ empty_enum_variants_with_brackets = "warn"
127127
deref_by_slicing = "warn"
128128
multiple_inherent_impl = "warn"
129129
map_with_unused_argument_over_ranges = "warn"
130+
partial_pub_fields = "warn"
130131
trait_duplication_in_bounds = "warn"
131132
type_repetition_in_bounds = "warn"
132133
checked_conversions = "warn"

crates/ironrdp-acceptor/src/connection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ impl Sequence for Acceptor {
713713
AcceptorState::Accepted {
714714
channels,
715715
client_capabilities,
716-
input_events: finalization.input_events,
716+
input_events: finalization.into_input_events(),
717717
}
718718
} else {
719719
AcceptorState::ConnectionFinalization {

crates/ironrdp-acceptor/src/finalization.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub struct FinalizationSequence {
1212
user_channel_id: u16,
1313
io_channel_id: u16,
1414

15-
pub input_events: Vec<Vec<u8>>,
15+
input_events: Vec<Vec<u8>>,
1616
}
1717

1818
#[derive(Default, Debug)]
@@ -190,6 +190,10 @@ impl FinalizationSequence {
190190
}
191191
}
192192

193+
pub fn into_input_events(self) -> Vec<Vec<u8>> {
194+
self.input_events
195+
}
196+
193197
pub fn is_done(&self) -> bool {
194198
self.state.is_terminal()
195199
}

crates/ironrdp-client/src/rdp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ async fn active_session(
660660
desktop_size,
661661
enable_server_pointer,
662662
pointer_software_rendering,
663-
} = connection_activation.state
663+
} = connection_activation.connection_activation_state()
664664
{
665665
debug!(?desktop_size, "Deactivation-Reactivation Sequence completed");
666666
// Update image size with the new desktop size.

crates/ironrdp-cliprdr/src/pdu/format_data/metafile.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub struct PackedMetafile<'a> {
4242
pub x_ext: u32,
4343
pub y_ext: u32,
4444
/// The variable sized contents of the metafile as specified in [MS-WMF] section 2
45-
data: Cow<'a, [u8]>,
45+
pub data: Cow<'a, [u8]>,
4646
}
4747

4848
impl PackedMetafile<'_> {
@@ -62,10 +62,6 @@ impl PackedMetafile<'_> {
6262
data: data.into(),
6363
}
6464
}
65-
66-
pub fn data(&self) -> &[u8] {
67-
&self.data
68-
}
6965
}
7066

7167
impl Encode for PackedMetafile<'_> {

crates/ironrdp-connector/src/connection.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ impl Sequence for ClientConnector {
553553
mut connection_activation,
554554
} => {
555555
let written = connection_activation.step(input, output)?;
556-
match connection_activation.state {
556+
match connection_activation.connection_activation_state() {
557557
ConnectionActivationState::ConnectionFinalization { .. } => (
558558
written,
559559
ClientConnectorState::ConnectionFinalization { connection_activation },
@@ -570,10 +570,10 @@ impl Sequence for ClientConnector {
570570
} => {
571571
let written = connection_activation.step(input, output)?;
572572

573-
let next_state = if !connection_activation.state.is_terminal() {
573+
let next_state = if !connection_activation.connection_activation_state().is_terminal() {
574574
ClientConnectorState::ConnectionFinalization { connection_activation }
575575
} else {
576-
match connection_activation.state {
576+
match connection_activation.connection_activation_state() {
577577
ConnectionActivationState::Finalized {
578578
io_channel_id,
579579
user_channel_id,

crates/ironrdp-connector/src/connection_activation.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use crate::{
2222
/// [Server Deactivate All PDU]: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-rdpbcgr/8a29971a-df3c-48da-add2-8ed9a05edc89
2323
#[derive(Debug, Clone)]
2424
pub struct ConnectionActivationSequence {
25-
pub state: ConnectionActivationState,
25+
state: ConnectionActivationState,
2626
config: Config,
2727
}
2828

@@ -37,6 +37,11 @@ impl ConnectionActivationSequence {
3737
}
3838
}
3939

40+
/// Returns the current state as a district type, rather than `&dyn State` provided by [`Self::state`].
41+
pub fn connection_activation_state(&self) -> ConnectionActivationState {
42+
self.state
43+
}
44+
4045
#[must_use]
4146
pub fn reset_clone(&self) -> Self {
4247
self.clone().reset()
@@ -215,7 +220,7 @@ impl Sequence for ConnectionActivationSequence {
215220
}
216221
}
217222

218-
#[derive(Default, Debug, Clone)]
223+
#[derive(Default, Debug, Copy, Clone)]
219224
pub enum ConnectionActivationState {
220225
#[default]
221226
Consumed,

crates/ironrdp-connector/src/connection_finalization.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use tracing::{debug, warn};
99

1010
use crate::{general_err, legacy, reason_err, ConnectorResult, Sequence, State, Written};
1111

12-
#[derive(Default, Debug, Clone)]
12+
#[derive(Default, Debug, Copy, Clone)]
1313
#[non_exhaustive]
1414
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
1515
pub enum ConnectionFinalizationState {
@@ -48,7 +48,7 @@ impl State for ConnectionFinalizationState {
4848
}
4949
}
5050

51-
#[derive(Debug, Clone)]
51+
#[derive(Debug, Copy, Clone)]
5252
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
5353
pub struct ConnectionFinalizationSequence {
5454
pub state: ConnectionFinalizationState,

crates/ironrdp-connector/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ pub trait ConnectorResultExt {
406406
impl<T> ConnectorResultExt for ConnectorResult<T> {
407407
fn with_context(self, context: &'static str) -> Self {
408408
self.map_err(|mut e| {
409-
e.context = context;
409+
e.set_context(context);
410410
e
411411
})
412412
}

crates/ironrdp-dvc/src/client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ impl SvcProcessor for DrdynvcClient {
116116
}
117117
DrdynvcServerPdu::Create(create_request) => {
118118
debug!("Got DVC Create Request PDU: {create_request:?}");
119-
let channel_name = create_request.channel_name;
120-
let channel_id = create_request.channel_id;
119+
let channel_id = create_request.channel_id();
120+
let channel_name = create_request.into_channel_name();
121121

122122
if !self.cap_handshake_done {
123123
debug!(
@@ -156,9 +156,9 @@ impl SvcProcessor for DrdynvcClient {
156156
}
157157
DrdynvcServerPdu::Close(close_request) => {
158158
debug!("Got DVC Close Request PDU: {close_request:?}");
159-
self.dynamic_channels.remove_by_channel_id(close_request.channel_id);
159+
self.dynamic_channels.remove_by_channel_id(close_request.channel_id());
160160

161-
let close_response = DrdynvcClientPdu::Close(ClosePdu::new(close_request.channel_id));
161+
let close_response = DrdynvcClientPdu::Close(ClosePdu::new(close_request.channel_id()));
162162

163163
debug!("Send DVC Close Response PDU: {close_response:?}");
164164
responses.push(SvcMessage::from(close_response));

0 commit comments

Comments
 (0)