Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix clippy warnings
  • Loading branch information
algesten committed Oct 9, 2021
commit 2b6dcf6d83a89929d20ab512211216faafa7e65c
6 changes: 3 additions & 3 deletions examples/broadcast/broadcast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async fn main() -> Result<()> {
tokio::spawn(async move {
// Create Track that we send video back to browser on
let local_track = Arc::new(TrackLocalStaticRTP::new(
track.codec().await.capability.clone(),
track.codec().await.capability,
"video".to_owned(),
"webrtc-rs".to_owned(),
));
Expand Down Expand Up @@ -186,7 +186,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);
Box::pin(async {})
}))
.await;
Expand Down Expand Up @@ -274,7 +274,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);
Box::pin(async {})
}))
.await;
Expand Down
4 changes: 2 additions & 2 deletions examples/data-channels-close/data-channels-close.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);
let (done_tx, mut done_rx) = tokio::sync::mpsc::channel::<()>(1);
Expand Down Expand Up @@ -187,7 +187,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
})).await;
})
Expand Down
2 changes: 1 addition & 1 deletion examples/data-channels-detach/data-channels-detach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open.", d_label2, d_id2);

Expand Down
4 changes: 2 additions & 2 deletions examples/data-channels/data-channels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);

Expand All @@ -148,7 +148,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
})).await;
})
Expand Down
2 changes: 1 addition & 1 deletion examples/insertable-streams/insertable-streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down
6 changes: 3 additions & 3 deletions examples/offer-answer/answer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async fn remote_handler(req: Request<Body>) -> Result<Response<Body>, hyper::Err
Ok(resp) => resp,
Err(err) => {
println!("{}", err);
return Err(err.into());
return Err(err);
}
};
//println!("remote_handler Response: {}", resp.status());
Expand Down Expand Up @@ -348,7 +348,7 @@ async fn main() -> Result<()> {
// Register channel opening handling
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);
Box::pin(async move {
Expand All @@ -371,7 +371,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async{})
})).await;
})
Expand Down
6 changes: 3 additions & 3 deletions examples/ortc/ortc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async fn main() -> Result<()> {
Box::pin(async move {
let d2 = Arc::clone(&d);
let d_label2 = d_label.clone();
let d_id2 = d_id.clone();
let d_id2 = d_id;
d.on_open(Box::new(move || {
println!("Data channel '{}'-'{}' open. Random messages will now be sent to any connected DataChannels every 5 seconds", d_label2, d_id2);

Expand All @@ -116,7 +116,7 @@ async fn main() -> Result<()> {
// Register text message handling
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
})).await;
})
Expand Down Expand Up @@ -204,7 +204,7 @@ async fn main() -> Result<()> {
let d_label = d.label().to_owned();
d.on_message(Box::new(move |msg: DataChannelMessage| {
let msg_str = String::from_utf8(msg.data.to_vec()).unwrap();
print!("Message from DataChannel '{}': '{}'\n", d_label, msg_str);
println!("Message from DataChannel '{}': '{}'", d_label, msg_str);
Box::pin(async {})
}))
.await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down
2 changes: 1 addition & 1 deletion examples/play-from-disk-vp8/play-from-disk-vp8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down
2 changes: 1 addition & 1 deletion examples/rtp-forwarder/rtp-forwarder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down
2 changes: 1 addition & 1 deletion examples/rtp-to-webrtc/rtp-to-webrtc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async fn main() -> Result<()> {
// This will notify you when the peer has connected/disconnected
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

if s == RTCPeerConnectionState::Failed {
// Wait until PeerConnection has had no network activity for 30 seconds or another failure. It may be reconnected using an ICE Restart.
Expand Down
2 changes: 1 addition & 1 deletion examples/swap-tracks/swap-tracks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ async fn main() -> Result<()> {
let done1 = Arc::clone(&done);
peer_connection
.on_peer_connection_state_change(Box::new(move |s: RTCPeerConnectionState| {
print!("Peer Connection State has changed: {}\n", s);
println!("Peer Connection State has changed: {}", s);

let done2 = Arc::clone(&done1);
Box::pin(async move {
Expand Down
6 changes: 3 additions & 3 deletions src/api/media_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ impl MediaEngine {
MediaEngine::add_codec(&mut self.video_codecs, codec);
Ok(())
}
_ => Err(Error::ErrUnknownType.into()),
_ => Err(Error::ErrUnknownType),
}
}

Expand All @@ -429,7 +429,7 @@ impl MediaEngine {
if *direction != RTCRtpTransceiverDirection::Recvonly
&& *direction != RTCRtpTransceiverDirection::Sendonly
{
return Err(Error::ErrRegisterHeaderExtensionInvalidDirection.into());
return Err(Error::ErrRegisterHeaderExtensionInvalidDirection);
}
}

Expand Down Expand Up @@ -529,7 +529,7 @@ impl MediaEngine {
}
}

Err(Error::ErrCodecNotFound.into())
Err(Error::ErrCodecNotFound)
}

/*TODO: func (m *MediaEngine) collectStats(collector *statsReportCollector) {
Expand Down
4 changes: 2 additions & 2 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ impl API {
let now = SystemTime::now();
for cert in &certificates {
if cert.expires().duration_since(now).is_err() {
return Err(Error::ErrCertificateExpired.into());
return Err(Error::ErrCertificateExpired);
}
}
} else {
Expand Down Expand Up @@ -126,7 +126,7 @@ impl API {
) -> Result<RTCDataChannel> {
// https://w3c.github.io/webrtc-pc/#peer-to-peer-data-api (Step #5)
if params.label.len() > 65535 {
return Err(Error::ErrStringSizeLimit.into());
return Err(Error::ErrStringSizeLimit);
}

let d = RTCDataChannel::new(params, Arc::clone(&self.setting_engine));
Expand Down
2 changes: 1 addition & 1 deletion src/api/setting_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl SettingEngine {
/// Act as dtls_transport Server, wait for ClientHello
pub fn set_answering_dtls_role(&mut self, role: DTLSRole) -> Result<()> {
if role != DTLSRole::Client && role != DTLSRole::Server {
return Err(Error::ErrSettingEngineSetAnsweringDTLSRole.into());
return Err(Error::ErrSettingEngineSetAnsweringDTLSRole);
}

self.answering_dtls_role = role;
Expand Down
12 changes: 6 additions & 6 deletions src/data/data_channel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ impl RTCDataChannel {

Ok(())
} else {
Err(Error::ErrSCTPNotEstablished.into())
Err(Error::ErrSCTPNotEstablished)
}
}

Expand Down Expand Up @@ -338,7 +338,7 @@ impl RTCDataChannel {
if let Some(dc) = &*data_channel {
Ok(dc.write_data_channel(data, false).await?)
} else {
Err(Error::ErrClosedPipe.into())
Err(Error::ErrClosedPipe)
}
}

Expand All @@ -350,13 +350,13 @@ impl RTCDataChannel {
if let Some(dc) = &*data_channel {
Ok(dc.write_data_channel(&Bytes::from(s), true).await?)
} else {
Err(Error::ErrClosedPipe.into())
Err(Error::ErrClosedPipe)
}
}

fn ensure_open(&self) -> Result<()> {
if self.ready_state() != RTCDataChannelState::Open {
Err(Error::ErrClosedPipe.into())
Err(Error::ErrClosedPipe)
} else {
Ok(())
}
Expand All @@ -372,7 +372,7 @@ impl RTCDataChannel {
/// resulting DataChannel object.
pub async fn detach(&self) -> Result<Arc<data::data_channel::DataChannel>> {
if !self.setting_engine.detach.data_channels {
return Err(Error::ErrDetachNotEnabled.into());
return Err(Error::ErrDetachNotEnabled);
}

let data_channel = self.data_channel.lock().await;
Expand All @@ -381,7 +381,7 @@ impl RTCDataChannel {

Ok(Arc::clone(dc))
} else {
Err(Error::ErrDetachBeforeOpened.into())
Err(Error::ErrDetachBeforeOpened)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/data/sctp_transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ impl RTCSctpTransport {

Ok(())
} else {
Err(Error::ErrSCTPTransportDTLS.into())
Err(Error::ErrSCTPTransportDTLS)
}
}

Expand Down Expand Up @@ -366,7 +366,7 @@ impl RTCSctpTransport {
}
}

Err(Error::ErrMaxDataChannelID.into())
Err(Error::ErrMaxDataChannelID)
}

pub(crate) async fn association(&self) -> Option<Arc<Association>> {
Expand Down
18 changes: 9 additions & 9 deletions src/media/dtls_transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl RTCDtlsTransport {
.extract_session_keys_from_dtls(conn_state, self.role().await == DTLSRole::Client)
.await?;
} else {
return Err(Error::ErrDtlsTransportNotStarted.into());
return Err(Error::ErrDtlsTransportNotStarted);
}

{
Expand Down Expand Up @@ -225,7 +225,7 @@ impl RTCDtlsTransport {
.extract_session_keys_from_dtls(conn_state, self.role().await == DTLSRole::Client)
.await?;
} else {
return Err(Error::ErrDtlsTransportNotStarted.into());
return Err(Error::ErrDtlsTransportNotStarted);
}

{
Expand Down Expand Up @@ -301,7 +301,7 @@ impl RTCDtlsTransport {
self.ensure_ice_conn()?;

if self.state() != RTCDtlsTransportState::New {
return Err(Error::ErrInvalidDTLSStart.into());
return Err(Error::ErrInvalidDTLSStart);
}

{
Expand All @@ -320,7 +320,7 @@ impl RTCDtlsTransport {
let certificate = if let Some(cert) = self.certificates.first() {
cert.certificate.clone()
} else {
return Err(Error::ErrNonCertificate.into());
return Err(Error::ErrNonCertificate);
};
self.state_change(RTCDtlsTransportState::Connecting).await;

Expand Down Expand Up @@ -399,7 +399,7 @@ impl RTCDtlsTransport {
}
_ => {
self.state_change(RTCDtlsTransportState::Failed).await;
return Err(Error::ErrNoSRTPProtectionProfile.into());
return Err(Error::ErrNoSRTPProtectionProfile);
}
};
}
Expand All @@ -415,7 +415,7 @@ impl RTCDtlsTransport {
let remote_certs = &dtls_conn.connection_state().await.peer_certificates;
if remote_certs.is_empty() {
self.state_change(RTCDtlsTransportState::Failed).await;
return Err(Error::ErrNoRemoteCertificate.into());
return Err(Error::ErrNoRemoteCertificate);
}

{
Expand Down Expand Up @@ -502,7 +502,7 @@ impl RTCDtlsTransport {
let remote_parameters = self.remote_parameters.lock().await;
for fp in &remote_parameters.fingerprints {
if fp.algorithm != "sha-256" {
return Err(Error::ErrUnsupportedFingerprintAlgorithm.into());
return Err(Error::ErrUnsupportedFingerprintAlgorithm);
}

let mut h = Sha256::new();
Expand All @@ -516,12 +516,12 @@ impl RTCDtlsTransport {
}
}

Err(Error::ErrNoMatchingCertificateFingerprint.into())
Err(Error::ErrNoMatchingCertificateFingerprint)
}

pub(crate) fn ensure_ice_conn(&self) -> Result<()> {
if self.ice_transport.state() == RTCIceTransportState::New {
Err(Error::ErrICEConnectionNotStarted.into())
Err(Error::ErrICEConnectionNotStarted)
} else {
Ok(())
}
Expand Down
Loading