Skip to content

Commit 845a0f8

Browse files
committed
refactor: adapt to breaking changes introduced by dicom-rs 0.9
1 parent f189dd0 commit 845a0f8

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/backend/dimse/association/client.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dicom::ul::pdu::{PDataValueType, PresentationContextResult};
1+
use dicom::ul::pdu::{PDataValueType, PresentationContextNegotiated};
22
use dicom::ul::Pdu;
33
use std::convert::identity;
44
use std::io::Write;
@@ -16,7 +16,7 @@ pub struct ClientAssociation {
1616
channel: Sender<Command>,
1717
uuid: Uuid,
1818
tcp_stream: TcpStream,
19-
presentation_context: Vec<PresentationContextResult>,
19+
presentation_context: Vec<PresentationContextNegotiated>,
2020
acceptor_max_pdu_length: u32,
2121
}
2222

@@ -39,7 +39,7 @@ impl ClientAssociation {
3939
.first()
4040
.is_some_and(|pdv| pdv.value_type == PDataValueType::Command);
4141
if is_command {
42-
association.send(pdu).map_err(AssociationError::Client)
42+
association.send(pdu).map_err(AssociationError::Association)
4343
} else {
4444
let data_length: usize = data.iter().map(|pdv| pdv.data.len()).sum();
4545
if data_length > association.acceptor_max_pdu_length() as usize {
@@ -52,11 +52,11 @@ impl ClientAssociation {
5252
}
5353
Ok(())
5454
} else {
55-
association.send(pdu).map_err(AssociationError::Client)
55+
association.send(pdu).map_err(AssociationError::Association)
5656
}
5757
}
5858
}
59-
_ => association.send(pdu).map_err(AssociationError::Client),
59+
_ => association.send(pdu).map_err(AssociationError::Association),
6060
}
6161
}
6262

@@ -120,7 +120,7 @@ impl ClientAssociation {
120120
}
121121
Command::Receive(reply_to) => {
122122
let receive_result =
123-
association.receive().map_err(AssociationError::Client);
123+
association.receive().map_err(AssociationError::Association);
124124
reply_to
125125
.send(receive_result)
126126
.map_err(|_| ChannelError::Closed)
@@ -197,7 +197,7 @@ impl Association for ClientAssociation {
197197
}
198198
}
199199

200-
fn presentation_contexts(&self) -> &[PresentationContextResult] {
200+
fn presentation_contexts(&self) -> &[PresentationContextNegotiated] {
201201
&self.presentation_context
202202
}
203203
}

src/backend/dimse/association/mod.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use dicom::ul::pdu::PresentationContextResult;
1+
use dicom::ul::pdu::{PresentationContextNegotiated, PresentationContextResult};
22
use dicom::ul::Pdu;
33
use std::time::Duration;
44
use thiserror::Error;
@@ -19,9 +19,7 @@ pub enum AssociationError {
1919
#[error("Failed to write P-DATA chunk: {0}")]
2020
ChunkWriter(std::io::Error),
2121
#[error(transparent)]
22-
Client(#[from] dicom::ul::association::client::Error),
23-
#[error(transparent)]
24-
Server(#[from] dicom::ul::association::server::Error),
22+
Association(#[from] dicom::ul::association::Error),
2523
}
2624

2725
pub trait Association {
@@ -31,7 +29,7 @@ pub trait Association {
3129

3230
fn close(&mut self);
3331

34-
fn presentation_contexts(&self) -> &[PresentationContextResult];
32+
fn presentation_contexts(&self) -> &[PresentationContextNegotiated];
3533
}
3634

3735
#[derive(Debug)]

src/backend/dimse/association/server.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::{oneshot, AskPattern, Association, AssociationError, ChannelError, Command, Sender};
22
use dicom::transfer_syntax::TransferSyntaxRegistry;
3-
use dicom::ul::{pdu::PresentationContextResult, Pdu};
3+
use dicom::ul::pdu::Pdu;
4+
use dicom::ul::pdu::PresentationContextNegotiated;
45
use std::convert::identity;
56
use std::io::ErrorKind;
67
use std::{net::TcpStream, thread, time::Duration};
@@ -11,7 +12,7 @@ use uuid::Uuid;
1112
pub struct ServerAssociation {
1213
uuid: Uuid,
1314
channel: Sender<Command>,
14-
presentation_contexts: Vec<PresentationContextResult>,
15+
presentation_contexts: Vec<PresentationContextNegotiated>,
1516
tcp_stream: TcpStream,
1617
}
1718

@@ -84,7 +85,7 @@ impl ServerAssociation {
8485
}
8586
Command::Receive(response) => {
8687
let receive_result =
87-
association.receive().map_err(AssociationError::Server);
88+
association.receive().map_err(AssociationError::Association);
8889
response
8990
.send(receive_result)
9091
.map_err(|_value| ChannelError::Closed)
@@ -101,7 +102,7 @@ impl ServerAssociation {
101102

102103
if let Err(e) = association.abort() {
103104
match e {
104-
dicom::ul::association::server::Error::WireSend { source, .. }
105+
dicom::ul::association::Error::WireSend { source, .. }
105106
if source.kind() == ErrorKind::BrokenPipe =>
106107
{
107108
// no-op, happens on MacOS if the TCP stream is already closed
@@ -153,7 +154,7 @@ impl Association for ServerAssociation {
153154
}
154155
}
155156

156-
fn presentation_contexts(&self) -> &[PresentationContextResult] {
157+
fn presentation_contexts(&self) -> &[PresentationContextNegotiated] {
157158
&self.presentation_contexts
158159
}
159160
}

0 commit comments

Comments
 (0)