Skip to content

Commit 1eebe5e

Browse files
committed
[#429] Fixed all clippy warnings
1 parent e201b18 commit 1eebe5e

File tree

7 files changed

+70
-46
lines changed

7 files changed

+70
-46
lines changed

iceoryx2-ffi/ffi/src/api/subscriber.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::api::{
1919
};
2020

2121
use iceoryx2::port::subscriber::Subscriber;
22-
use iceoryx2::port::update_connections::{ConnectionFailure, UpdateConnections};
22+
use iceoryx2::port::update_connections::ConnectionFailure;
2323
use iceoryx2::port::ReceiveError;
2424
use iceoryx2::prelude::*;
2525
use iceoryx2_bb_elementary::static_assert::*;

iceoryx2/src/port/details/sender.rs

-13
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,6 @@ impl<Service: service::Service> Sender<Service> {
211211
Ok(number_of_recipients)
212212
}
213213

214-
pub(crate) fn set_channel_state(
215-
&self,
216-
channel_id: ChannelId,
217-
connection_id: usize,
218-
state: u64,
219-
) -> bool {
220-
if let Some(ref connection) = self.get(connection_id) {
221-
connection.sender.set_channel_state(channel_id, state)
222-
} else {
223-
false
224-
}
225-
}
226-
227214
pub(crate) fn has_channel_state(
228215
&self,
229216
channel_id: ChannelId,

iceoryx2/src/port/server.rs

+21-25
Original file line numberDiff line numberDiff line change
@@ -408,37 +408,33 @@ impl<
408408
&*(chunk.header as *const service::header::request_response::RequestHeader)
409409
};
410410

411-
match self
411+
if let Some(connection_id) = self
412412
.shared_state
413413
.response_sender
414414
.get_connection_id_of(header.client_port_id.value())
415415
{
416-
Some(connection_id) => {
417-
let active_request = ActiveRequest {
418-
details,
419-
request_id: header.request_id,
420-
channel_id: header.channel_id,
421-
connection_id,
422-
shared_state: self.shared_state.clone(),
423-
ptr: unsafe {
424-
RawSample::new_unchecked(
425-
chunk.header.cast(),
426-
chunk.user_header.cast(),
427-
chunk.payload.cast::<RequestPayload>(),
428-
)
429-
},
430-
_response_payload: PhantomData,
431-
_response_header: PhantomData,
432-
};
433-
434-
if !self.allow_fire_and_forget && !active_request.is_connected() {
435-
continue;
436-
}
437-
438-
return Ok(Some(active_request));
416+
let active_request = ActiveRequest {
417+
details,
418+
request_id: header.request_id,
419+
channel_id: header.channel_id,
420+
connection_id,
421+
shared_state: self.shared_state.clone(),
422+
ptr: unsafe {
423+
RawSample::new_unchecked(
424+
chunk.header.cast(),
425+
chunk.user_header.cast(),
426+
chunk.payload.cast::<RequestPayload>(),
427+
)
428+
},
429+
_response_payload: PhantomData,
430+
_response_header: PhantomData,
431+
};
432+
433+
if !self.allow_fire_and_forget && !active_request.is_connected() {
434+
continue;
439435
}
440436

441-
None => (),
437+
return Ok(Some(active_request));
442438
}
443439
}
444440
None => return Ok(None),

iceoryx2/src/request_mut.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ impl<
8989
> Drop for RequestMut<Service, RequestPayload, RequestHeader, ResponsePayload, ResponseHeader>
9090
{
9191
fn drop(&mut self) {
92-
if unsafe { &mut *self.client_shared_state.available_channel_ids.get() }
92+
if !unsafe { &mut *self.client_shared_state.available_channel_ids.get() }
9393
.push(self.header().channel_id)
94-
== false
9594
{
9695
fatal_panic!(from self,
9796
"This should never happen! The channel id could not be returned.");

iceoryx2/src/response.rs

+38
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,34 @@
1010
//
1111
// SPDX-License-Identifier: Apache-2.0 OR MIT
1212

13+
//! # Example
14+
//!
15+
//! ## Typed API
16+
//!
17+
//! ```
18+
//! use iceoryx2::prelude::*;
19+
//! # fn main() -> Result<(), Box<dyn core::error::Error>> {
20+
//! # let node = NodeBuilder::new().create::<ipc::Service>()?;
21+
//! #
22+
//! # let service = node.service_builder(&"My/Funk/ServiceName".try_into()?)
23+
//! # .request_response::<u64, u64>()
24+
//! # .open_or_create()?;
25+
//! #
26+
//! let client = service.client_builder().create()?;
27+
//! # let server = service.server_builder().create()?;
28+
//! let pending_response = client.send_copy(0)?;
29+
//! # let active_request = server.receive()?.unwrap();
30+
//! # active_request.send_copy(0)?;
31+
//!
32+
//! if let Some(response) = pending_response.receive()? {
33+
//! println!("received response: {} from: {}",
34+
//! response.payload(), response.header().server_id());
35+
//! }
36+
//!
37+
//! # Ok(())
38+
//! # }
39+
//! ```
40+
1341
use core::fmt::Debug;
1442
use core::ops::Deref;
1543

@@ -22,6 +50,10 @@ use crate::port::port_identifiers::UniqueServerId;
2250
use crate::raw_sample::RawSample;
2351
use crate::service;
2452

53+
/// It stores the payload and can be received by the
54+
/// [`PendingResponse`](crate::pending_response::PendingResponse) after a
55+
/// [`RequestMut`](crate::request_mut::RequestMut) was sent to a
56+
/// [`Server`](crate::port::server::Server) via the [`Client`](crate::port::client::Client).
2557
pub struct Response<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: Debug>
2658
{
2759
pub(crate) ptr: RawSample<
@@ -85,18 +117,24 @@ impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: D
85117
impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: Debug>
86118
Response<Service, ResponsePayload, ResponseHeader>
87119
{
120+
/// Returns a reference to the
121+
/// [`ResponseHeader`](service::header::request_response::ResponseHeader).
88122
pub fn header(&self) -> &service::header::request_response::ResponseHeader {
89123
self.ptr.as_header_ref()
90124
}
91125

126+
/// Returns a reference to the user header of the response.
92127
pub fn user_header(&self) -> &ResponseHeader {
93128
self.ptr.as_user_header_ref()
94129
}
95130

131+
/// Returns a reference to the payload of the response.
96132
pub fn payload(&self) -> &ResponsePayload {
97133
self.ptr.as_payload_ref()
98134
}
99135

136+
/// Returns the [`UniqueServerId`] of the [`Server`](crate::port::server::Server) which sent
137+
/// the [`Response`].
100138
pub fn origin(&self) -> UniqueServerId {
101139
UniqueServerId(UniqueSystemId::from(self.details.origin))
102140
}

iceoryx2/src/response_mut.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@
3939
//! # }
4040
//! ```
4141
42+
extern crate alloc;
43+
44+
use alloc::sync::Arc;
4245
use core::{
4346
fmt::Debug,
4447
marker::PhantomData,
4548
ops::{Deref, DerefMut},
4649
};
47-
use std::sync::Arc;
4850

4951
use iceoryx2_bb_log::fail;
5052
use iceoryx2_cal::{shm_allocator::PointerOffset, zero_copy_connection::ChannelId};
@@ -82,7 +84,7 @@ pub struct ResponseMut<Service: service::Service, ResponsePayload: Debug, Respon
8284
impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: Debug> Debug
8385
for ResponseMut<Service, ResponsePayload, ResponseHeader>
8486
{
85-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
87+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
8688
write!(
8789
f,
8890
"ResponseMut<{}, {}, {}> {{ ptr: {:?}, offset_to_chunk: {:?}, sample_size: {}, channel_id: {} }}",
@@ -127,7 +129,8 @@ impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: D
127129
impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: Debug>
128130
ResponseMut<Service, ResponsePayload, ResponseHeader>
129131
{
130-
/// Returns a reference to the header of the response.
132+
/// Returns a reference to the
133+
/// [`ResponseHeader`](service::header::request_response::ResponseHeader).
131134
///
132135
/// ```
133136
/// use iceoryx2::prelude::*;

iceoryx2/src/response_mut_uninit.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,16 @@ pub struct ResponseMutUninit<
6666
impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: Debug> Debug
6767
for ResponseMutUninit<Service, ResponsePayload, ResponseHeader>
6868
{
69-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
69+
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
7070
write!(f, "ResponseMut {{ response: {:?} }}", self.response)
7171
}
7272
}
7373

7474
impl<Service: crate::service::Service, ResponsePayload: Debug, ResponseHeader: Debug>
7575
ResponseMutUninit<Service, ResponsePayload, ResponseHeader>
7676
{
77-
/// Returns a reference to the header of the response.
77+
/// Returns a reference to the
78+
/// [`ResponseHeader`](service::header::request_response::ResponseHeader).
7879
///
7980
/// ```
8081
/// use iceoryx2::prelude::*;

0 commit comments

Comments
 (0)