Skip to content

Commit

Permalink
Revert "[ul] Recover API compatibility with 0.7.1"
Browse files Browse the repository at this point in the history
  • Loading branch information
Enet4 authored Nov 1, 2024
1 parent 9688a97 commit 61d484a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 56 deletions.
35 changes: 11 additions & 24 deletions ul/src/association/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,12 @@ pub enum Error {
/// no presentation contexts accepted by the server
NoAcceptedPresentationContexts { backtrace: Backtrace },

/// failed to write PDU message
/// failed to send PDU message
#[non_exhaustive]
Send {
#[snafu(backtrace)]
source: crate::pdu::writer::Error,
},
Send { source: std::io::Error },

/// failed to send PDU message on wire
#[non_exhaustive]
WireSend {
source: std::io::Error,
backtrace: Backtrace,
},

/// Operation timed out
#[non_exhaustive]
Timeout {
source: std::io::Error,
backtrace: Backtrace,
Expand Down Expand Up @@ -682,7 +672,7 @@ impl<'a> ClientAssociationOptions<'a> {
// send request

write_pdu(&mut buffer, &msg).context(SendRequestSnafu)?;
socket.write_all(&buffer).context(WireSendSnafu)?;
socket.write_all(&buffer).context(SendSnafu)?;
buffer.clear();

let msg = get_client_pdu(&mut socket, MAXIMUM_PDU_SIZE, self.strict)?;
Expand Down Expand Up @@ -951,7 +941,7 @@ where
}
.fail();
}
self.socket.write_all(&self.buffer).context(WireSendSnafu)
self.socket.write_all(&self.buffer).context(SendSnafu)
}

/// Read a PDU message from the other intervenient.
Expand Down Expand Up @@ -1089,7 +1079,7 @@ pub mod non_blocking {
ConnectSnafu, ConnectionClosedSnafu, MissingAbstractSyntaxSnafu,
NoAcceptedPresentationContextsSnafu, ProtocolVersionMismatchSnafu,
ReceiveResponseSnafu, ReceiveSnafu, RejectedSnafu, SendRequestSnafu,
ToAddressSnafu, UnexpectedResponseSnafu, UnknownResponseSnafu, WireSendSnafu,
ToAddressSnafu, UnexpectedResponseSnafu, UnknownResponseSnafu,
},
pdata::non_blocking::{AsyncPDataWriter, PDataReader},
},
Expand All @@ -1102,7 +1092,7 @@ pub mod non_blocking {
};

use super::{
ClientAssociation, ClientAssociationOptions, CloseSocket, Release, Result,
ClientAssociation, ClientAssociationOptions, CloseSocket, Release, Result, SendSnafu,
SendTooLongPduSnafu, TimeoutSnafu,
};
use bytes::{Buf, BytesMut};
Expand Down Expand Up @@ -1278,7 +1268,7 @@ pub mod non_blocking {
// send request
write_pdu(&mut buffer, &msg).context(SendRequestSnafu)?;
timeout(write_timeout, async {
socket.write_all(&buffer).await.context(WireSendSnafu)?;
socket.write_all(&buffer).await.context(SendSnafu)?;
Ok(())
})
.await?;
Expand Down Expand Up @@ -1333,7 +1323,7 @@ pub mod non_blocking {
},
);
let _ = timeout(write_timeout, async {
socket.write_all(&buffer).await.context(WireSendSnafu)
socket.write_all(&buffer).await.context(SendSnafu)
})
.await;
buffer.clear();
Expand Down Expand Up @@ -1365,7 +1355,7 @@ pub mod non_blocking {
},
);
let _ = timeout(write_timeout, async {
socket.write_all(&buffer).await.context(WireSendSnafu)
socket.write_all(&buffer).await.context(SendSnafu)
})
.await;
UnexpectedResponseSnafu { pdu }.fail()
Expand All @@ -1379,7 +1369,7 @@ pub mod non_blocking {
},
);
let _ = timeout(write_timeout, async {
socket.write_all(&buffer).await.context(WireSendSnafu)
socket.write_all(&buffer).await.context(SendSnafu)
})
.await;
UnknownResponseSnafu { pdu }.fail()
Expand Down Expand Up @@ -1453,10 +1443,7 @@ pub mod non_blocking {
.fail();
}
timeout(self.write_timeout, async {
self.socket
.write_all(&self.buffer)
.await
.context(WireSendSnafu)
self.socket.write_all(&self.buffer).await.context(SendSnafu)
})
.await
}
Expand Down
3 changes: 0 additions & 3 deletions ul/src/association/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,4 @@ mod uid;
pub(crate) mod pdata;

pub use client::{ClientAssociation, ClientAssociationOptions};
pub use pdata::{PDataReader, PDataWriter};
#[cfg(feature = "async")]
pub use pdata::non_blocking::AsyncPDataWriter;
pub use server::{ServerAssociation, ServerAssociationOptions};
31 changes: 4 additions & 27 deletions ul/src/pdu/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,11 @@ use dicom_encoding::text::{DefaultCharacterSetCodec, TextCodec};
use snafu::{ensure, OptionExt, ResultExt};
use tracing::warn;

pub type Error = crate::pdu::ReadError;

pub type Result<T> = std::result::Result<T, Error>;

/// The default maximum PDU size
#[deprecated(since = "0.7.2", note = "Use dicom_ul::pdu::DEFAULT_MAX_PDU instead")]
pub const DEFAULT_MAX_PDU: u32 = crate::pdu::DEFAULT_MAX_PDU;

/// The minimum PDU size,
/// as specified by the standard
#[deprecated(since = "0.7.2", note = "Use dicom_ul::pdu::MINIMUM_PDU_SIZE instead")]
pub const MINIMUM_PDU_SIZE: u32 = crate::pdu::MINIMUM_PDU_SIZE;

/// The maximum PDU size,
/// as specified by the standard
#[deprecated(since = "0.7.2", note = "Use dicom_ul::pdu::MAXIMUM_PDU_SIZE instead")]
pub const MAXIMUM_PDU_SIZE: u32 = crate::pdu::MAXIMUM_PDU_SIZE;

/// The length of the PDU header in bytes,
/// comprising the PDU type (1 byte),
/// reserved byte (1 byte),
/// and PDU length (4 bytes).
#[deprecated(since = "0.7.2", note = "Use dicom_ul::pdu::PDU_HEADER_SIZE instead")]
pub const PDU_HEADER_SIZE: u32 = crate::pdu::PDU_HEADER_SIZE;
pub type Result<T> = std::result::Result<T, ReadError>;

pub fn read_pdu(mut buf: impl Buf, max_pdu_length: u32, strict: bool) -> Result<Option<Pdu>> {
ensure!(
(super::MINIMUM_PDU_SIZE..=super::MAXIMUM_PDU_SIZE).contains(&max_pdu_length),
(MINIMUM_PDU_SIZE..=MAXIMUM_PDU_SIZE).contains(&max_pdu_length),
InvalidMaxPduSnafu { max_pdu_length }
);

Expand Down Expand Up @@ -62,10 +39,10 @@ pub fn read_pdu(mut buf: impl Buf, max_pdu_length: u32, strict: bool) -> Result<
);
} else if pdu_length > max_pdu_length {
ensure!(
pdu_length <= super::MAXIMUM_PDU_SIZE,
pdu_length <= MAXIMUM_PDU_SIZE,
PduTooLargeSnafu {
pdu_length,
max_pdu_length: super::MAXIMUM_PDU_SIZE
max_pdu_length: MAXIMUM_PDU_SIZE
}
);
tracing::warn!(
Expand Down
2 changes: 0 additions & 2 deletions ul/src/pdu/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ use dicom_encoding::text::TextCodec;
use snafu::{Backtrace, ResultExt, Snafu};
use std::io::Write;

pub type Error = crate::pdu::WriteError;

pub type Result<T> = std::result::Result<T, WriteError>;

#[derive(Debug, Snafu)]
Expand Down

0 comments on commit 61d484a

Please sign in to comment.