Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

Client type

The client itself is fairly simple. There are only 3 fields that the end-user should care about: server (the address of the Orthanc server, an HTTP(S) URL), username and password.

Creating a new client instance:

let client = Client::new("http://localhost:8042");

Authentication (setting username/password) can be done by calling the auth method:

client.auth("username", "password");

Or combined:

let client = Client::new("http://localhost:8042").auth("username", "password");

Implementations§

Source§

impl Client

Source

pub fn new(server: impl Into<String>) -> Client

Creates a new client instance

let client = Client::new("http://localhost:8042");
Source

pub fn auth( self, username: impl Into<String>, password: impl Into<String>, ) -> Client

Adds authentication to the client instance

let client = Client::new("http://localhost:8042").auth("username", "password");
Source

pub fn modalities(&self) -> Result<Vec<String>, Error>

List modalities

Source

pub fn modalities_expanded(&self) -> Result<HashMap<String, Modality>, Error>

List all modalities in an expanded format

Source

pub fn create_modality( &self, name: &str, modality: Modality, ) -> Result<(), Error>

Create a modality

Source

pub fn modify_modality( &self, name: &str, modality: Modality, ) -> Result<(), Error>

Modify a modality

Source

pub fn delete_modality(&self, name: &str) -> Result<(), Error>

Delete a modality

Source

pub fn modality_echo( &self, modality: &str, timeout: Option<u32>, ) -> Result<(), Error>

Send a C-ECHO request to a remote modality

If no error is returned, the request was successful

Source

pub fn echo(&self, modality: &str, timeout: Option<u32>) -> Result<(), Error>

👎Deprecated since 0.8.0: Renamed to modality_echo

Send a C-ECHO request to a remote modality

If no error is returned, the request was successful

Source

pub fn modality_store( &self, modality: &str, ids: &[&str], ) -> Result<ModalityStoreResult, Error>

Send a C-STORE DICOM request to a remote modality

ids is a slice of entity IDs to send. An ID can signify either of Patient, Study, Series or Instance

Source

pub fn store( &self, modality: &str, ids: &[&str], ) -> Result<ModalityStoreResult, Error>

👎Deprecated since 0.8.0: Renamed to modality_store

Send a C-STORE DICOM request to a remote modality

ids is a slice of entity IDs to send. An ID can signify either of Patient, Study, Series or Instance

Source

pub fn modality_move( &self, modality: &str, move_request: ModalityMove, ) -> Result<(), Error>

Send a C-MOVE request to a remote modality

If no error is returned, the request was successful

Source

pub fn modality_find( &self, modality: &str, level: EntityKind, query: HashMap<String, String>, normalize: Option<bool>, ) -> Result<ModalityFindResult, Error>

Send a C-FIND request to a remote modality

If no error is returned, the request was successful

Source

pub fn peers(&self) -> Result<Vec<String>, Error>

List peers

Source

pub fn peers_expanded(&self) -> Result<HashMap<String, Peer>, Error>

List all peers in an expanded format

Source

pub fn create_peer(&self, name: &str, peer: Peer) -> Result<(), Error>

Create a peer

Source

pub fn modify_peer(&self, name: &str, peer: Peer) -> Result<(), Error>

Modify a peer

Source

pub fn delete_peer(&self, name: &str) -> Result<(), Error>

Delete a peer

Source

pub fn peer_store( &self, peer: &str, ids: &[&str], ) -> Result<PeerStoreResult, Error>

Send entities to a peer

ids is a slice of entity IDs to send. An ID can signify either of Patient, Study, Series or Instance

Source

pub fn patients(&self) -> Result<Vec<String>, Error>

List patients

Source

pub fn patients_expanded(&self) -> Result<Vec<Patient>, Error>

List all patients in an expanded format

Source

pub fn patient(&self, id: &str) -> Result<Patient, Error>

Get a patient by its ID

Source

pub fn patient_dicom<W: Write>(&self, id: &str, writer: W) -> Result<(), Error>

Download a patient as a collection of DICOM files

Accepts a mutable reference to an object, that implements a Write trait, and mutates the object, writing the data into it in a streaming fashion.

Streamed data is a ZIP archive

Example:

let mut file = fs::File::create("/tmp/patient.zip").unwrap();
client().patient_dicom("3693b9d5-8b0e2a80-2cf45dda-d19e7c22-8749103c", &mut file).unwrap();
Source

pub fn anonymize_patient( &self, id: &str, anonymization: Option<Anonymization>, ) -> Result<ModificationResult, Error>

Anonymize a patient

Source

pub fn modify_patient( &self, id: &str, modification: Modification, ) -> Result<ModificationResult, Error>

Modify a patient

Source

pub fn delete_patient(&self, id: &str) -> Result<RemainingAncestor, Error>

Delete a patient

Source

pub fn studies(&self) -> Result<Vec<String>, Error>

List studies

Source

pub fn studies_expanded(&self) -> Result<Vec<Study>, Error>

List all studies in an expanded format

Source

pub fn study(&self, id: &str) -> Result<Study, Error>

Get a study by its ID

Source

pub fn study_dicom<W: Write>(&self, id: &str, writer: W) -> Result<(), Error>

Download a study as a collection of DICOM files

Accepts a mutable reference to an object, that implements a Write trait, and mutates the object, writing the data into it in a streaming fashion.

Streamed data is a ZIP archive

Example:

let mut file = fs::File::create("/tmp/study.zip").unwrap();
client().study_dicom("3693b9d5-8b0e2a80-2cf45dda-d19e7c22-8749103c", &mut file).unwrap();
Source

pub fn anonymize_study( &self, id: &str, anonymization: Option<Anonymization>, ) -> Result<ModificationResult, Error>

Anonymize a study

Source

pub fn modify_study( &self, id: &str, modification: Modification, ) -> Result<ModificationResult, Error>

Modify a study

Source

pub fn delete_study(&self, id: &str) -> Result<RemainingAncestor, Error>

Delete a study

Source

pub fn series_list(&self) -> Result<Vec<String>, Error>

List series

Source

pub fn series_expanded(&self) -> Result<Vec<Series>, Error>

List all series in an expanded format

Source

pub fn series(&self, id: &str) -> Result<Series, Error>

Get a series by its ID

Source

pub fn series_dicom<W: Write>(&self, id: &str, writer: W) -> Result<(), Error>

Download a series as a collection of DICOM files

Accepts a mutable reference to an object, that implements a Write trait, and mutates the object, writing the data into it in a streaming fashion.

Streamed data is a ZIP archive

Example:

let mut file = fs::File::create("/tmp/series.zip").unwrap();
client().series_dicom("3693b9d5-8b0e2a80-2cf45dda-d19e7c22-8749103c", &mut file).unwrap();
Source

pub fn anonymize_series( &self, id: &str, anonymization: Option<Anonymization>, ) -> Result<ModificationResult, Error>

Anonymize a series

Source

pub fn modify_series( &self, id: &str, modification: Modification, ) -> Result<ModificationResult, Error>

Modify a series

Source

pub fn delete_series(&self, id: &str) -> Result<RemainingAncestor, Error>

Delete a series

Source

pub fn instances(&self) -> Result<Vec<String>, Error>

List instances

Source

pub fn instances_expanded(&self) -> Result<Vec<Instance>, Error>

List all instances in an expanded format

Source

pub fn instance(&self, id: &str) -> Result<Instance, Error>

Get an instance by its ID

Source

pub fn instance_tags(&self, id: &str) -> Result<Value, Error>

Get all DICOM tags of an instance in a simplified format

See related Orthanc documentation section for details

Source

pub fn instance_tags_expanded(&self, id: &str) -> Result<Value, Error>

Get all DICOM tags of an instance in an expanded format

See related Orthanc documentation section for details

Source

pub fn instance_content(&self, id: &str) -> Result<Vec<String>, Error>

Get all DICOM tags’ codings of an instance

Returns a Vec<String> of the following format: ["0008-0018", "0040-0260", "0040-0254"]

Source

pub fn instance_tag(&self, id: &str, tag: &str) -> Result<String, Error>

Get the value of a specific DICOM tag of an instance

tag is the DICOM tag coding, e.g. 0008-0018

Source

pub fn instance_dicom<W: Write>(&self, id: &str, writer: W) -> Result<(), Error>

Download an instance as a DICOM file

Accepts a mutable reference to an object, that implements a Write trait, and mutates the object, writing the data into it in a streaming fashion.

Example:

let mut file = fs::File::create("/tmp/instance.dcm").unwrap();
client().instance_dicom("3693b9d5-8b0e2a80-2cf45dda-d19e7c22-8749103c", &mut file).unwrap();
Source

pub fn anonymize_instance<W: Write>( &self, id: &str, anonymization: Option<Anonymization>, writer: W, ) -> Result<(), Error>

Anonymize an instance

Accepts a mutable reference to an object, that implements a Write trait, and mutates the object, writing the data into it in a streaming fashion.

Example:

let mut file = fs::File::create("/tmp/anonymized_instance.dcm").unwrap();
client().anonymize_instance("3693b9d5-8b0e2a80-2cf45dda-d19e7c22-8749103c", None, &mut file).unwrap();
Source

pub fn modify_instance<W: Write>( &self, id: &str, modification: Modification, writer: W, ) -> Result<(), Error>

Modify an instance

Accepts a mutable reference to an object, that implements a Write trait, and mutates the object, writing the data into it in a streaming fashion.

Example:

let mut file = fs::File::create("/tmp/modified_instance.dcm").unwrap();
let modification = Modification {
    replace: None,
    remove: vec!["PatientName"],
    force: false,
};
client().modify_instance("3693b9d5-8b0e2a80-2cf45dda-d19e7c22-8749103c", modification, &mut file).unwrap();
Source

pub fn delete_instance(&self, id: &str) -> Result<RemainingAncestor, Error>

Delete an instance

Source

pub fn queries(&self) -> Result<Vec<String>, Error>

List queries

Source

pub fn query_level(&self, id: &str) -> Result<EntityKind, Error>

Get query level

Source

pub fn query_modality(&self, id: &str) -> Result<String, Error>

Get query modality

Source

pub fn query_query(&self, id: &str) -> Result<Value, Error>

Get query query

Source

pub fn query_answers(&self, id: &str) -> Result<Vec<String>, Error>

List query answers

Source

pub fn query_answer(&self, id: &str, answer_id: &str) -> Result<Value, Error>

Get query answer

Source

pub fn retrieve_query_answer( &self, id: &str, answer_id: &str, target_aet: Option<&str>, ) -> Result<(), Error>

Retrieve a single query answer

Source

pub fn retrieve_query_answers( &self, id: &str, target_aet: Option<&str>, ) -> Result<(), Error>

Retrieve all query answers

Source

pub fn system(&self) -> Result<System, Error>

System information

Source

pub fn upload(&self, data: &[u8]) -> Result<UploadResult, Error>

Upload a DICOM file to Orthanc

let data = fs::read("/tmp/instance.dcm").unwrap();
let client = Client::new("http://localhost:8042");
client.upload(&data).unwrap();
Source

pub fn search<T: Entity>( &self, query: HashMap<String, String>, ) -> Result<Vec<T>, Error>

Search for Entities in Orthanc

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,