Skip to content

Commit cfad623

Browse files
committed
rustfmt
1 parent 7586321 commit cfad623

File tree

12 files changed

+134
-99
lines changed

12 files changed

+134
-99
lines changed

core/src/header.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use std::str::{from_utf8, FromStr};
1313
pub trait HasLength {
1414
/// Retrieve the value data's length as specified by the data element or
1515
/// item, in bytes.
16-
///
16+
///
1717
/// It is named `length` to make it distinct from the conventional method
1818
/// signature `len(&self) -> usize` for the number of elements of a
1919
/// collection.
20-
///
20+
///
2121
/// According to the standard, the concrete value size may be undefined,
2222
/// which can be the case for sequence elements or specific primitive
2323
/// values.
@@ -47,7 +47,7 @@ pub trait Header: HasLength {
4747
}
4848

4949
/// Stub type representing a non-existing DICOM object.
50-
///
50+
///
5151
/// This type implements `HasLength`, but cannot be instantiated.
5252
/// This makes it so that `Value<EmptyObject>` is sure to be either a primitive
5353
/// value or a sequence with no items.
@@ -141,7 +141,6 @@ impl<'a, I> Header for &'a DataElement<I> {
141141
fn tag(&self) -> Tag {
142142
(**self).tag()
143143
}
144-
145144
}
146145

147146
impl<'v, I> HasLength for DataElementRef<'v, I> {
@@ -200,7 +199,7 @@ where
200199
I: HasLength,
201200
{
202201
/// Create a primitive data element from the given parts.
203-
///
202+
///
204203
/// This method will not check whether the value representation is
205204
/// compatible with the given value.
206205
pub fn new(tag: Tag, vr: VR, value: Value<I>) -> Self {

encoding/src/encode/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -369,43 +369,43 @@ where
369369
{
370370
fn encode_tag(&self, to: &mut W, tag: Tag) -> Result<()>
371371
where
372-
W: Write
372+
W: Write,
373373
{
374374
(**self).encode_tag(to, tag)
375375
}
376376

377377
fn encode_element_header(&self, to: &mut W, de: DataElementHeader) -> Result<usize>
378378
where
379-
W: Write
379+
W: Write,
380380
{
381381
(**self).encode_element_header(to, de)
382382
}
383383

384384
fn encode_item_header(&self, to: &mut W, len: u32) -> Result<()>
385385
where
386-
W: Write
386+
W: Write,
387387
{
388388
(**self).encode_item_header(to, len)
389389
}
390390

391391
fn encode_item_delimiter(&self, to: &mut W) -> Result<()>
392392
where
393-
W: Write
393+
W: Write,
394394
{
395395
(**self).encode_item_delimiter(to)
396396
}
397397

398398
fn encode_sequence_delimiter(&self, to: &mut W) -> Result<()>
399399
where
400-
W: Write
400+
W: Write,
401401
{
402402
(**self).encode_sequence_delimiter(to)
403403
}
404404

405405
/// Encode and write a primitive DICOM value to the given destination.
406406
fn encode_primitive(&self, to: &mut W, value: &PrimitiveValue) -> Result<usize>
407407
where
408-
W: Write
408+
W: Write,
409409
{
410410
(**self).encode_primitive(to, value)
411411
}
@@ -417,43 +417,43 @@ where
417417
{
418418
fn encode_tag(&self, to: &mut W, tag: Tag) -> Result<()>
419419
where
420-
W: Write
420+
W: Write,
421421
{
422422
(**self).encode_tag(to, tag)
423423
}
424424

425425
fn encode_element_header(&self, to: &mut W, de: DataElementHeader) -> Result<usize>
426426
where
427-
W: Write
427+
W: Write,
428428
{
429429
(**self).encode_element_header(to, de)
430430
}
431431

432432
fn encode_item_header(&self, to: &mut W, len: u32) -> Result<()>
433433
where
434-
W: Write
434+
W: Write,
435435
{
436436
(**self).encode_item_header(to, len)
437437
}
438438

439439
fn encode_item_delimiter(&self, to: &mut W) -> Result<()>
440440
where
441-
W: Write
441+
W: Write,
442442
{
443443
(**self).encode_item_delimiter(to)
444444
}
445445

446446
fn encode_sequence_delimiter(&self, to: &mut W) -> Result<()>
447447
where
448-
W: Write
448+
W: Write,
449449
{
450450
(**self).encode_sequence_delimiter(to)
451451
}
452452

453453
/// Encode and write a primitive DICOM value to the given destination.
454454
fn encode_primitive(&self, to: &mut W, value: &PrimitiveValue) -> Result<usize>
455455
where
456-
W: Write
456+
W: Write,
457457
{
458458
(**self).encode_primitive(to, value)
459459
}

encoding/src/text.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ where
6060
}
6161

6262
/// Type alias for a type erased text codec.
63-
///
63+
///
6464
/// It is important because stateful decoders may need to change the expected
6565
/// text encoding format at run-time.
6666
pub type DynamicTextCodec = Box<dyn TextCodec>;

encoding/src/transfer_syntax/implicit_le.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,9 @@ mod tests {
363363
// don't read any data, just skip
364364
// cursor should be @ #34 after skipping
365365
assert_eq!(
366-
cursor.seek(SeekFrom::Current(elem.length().0 as i64)).unwrap(),
366+
cursor
367+
.seek(SeekFrom::Current(elem.length().0 as i64))
368+
.unwrap(),
367369
34
368370
);
369371
}

encoding/src/transfer_syntax/mod.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -323,18 +323,15 @@ impl<A> TransferSyntax<A> {
323323
W: ?Sized + Write,
324324
{
325325
match (self.byte_order, self.explicit_vr) {
326-
(Endianness::Little, false) => Some(Box::new(
327-
EncoderFor::new(
328-
implicit_le::ImplicitVRLittleEndianEncoder::default())),
329-
),
330-
(Endianness::Little, true) => Some(Box::new(
331-
EncoderFor::new(
332-
explicit_le::ExplicitVRLittleEndianEncoder::default())),
333-
),
334-
(Endianness::Big, true) => Some(Box::new(
335-
EncoderFor::new(
336-
explicit_be::ExplicitVRBigEndianEncoder::default())),
337-
),
326+
(Endianness::Little, false) => Some(Box::new(EncoderFor::new(
327+
implicit_le::ImplicitVRLittleEndianEncoder::default(),
328+
))),
329+
(Endianness::Little, true) => Some(Box::new(EncoderFor::new(
330+
explicit_le::ExplicitVRLittleEndianEncoder::default(),
331+
))),
332+
(Endianness::Big, true) => Some(Box::new(EncoderFor::new(
333+
explicit_be::ExplicitVRBigEndianEncoder::default(),
334+
))),
338335
_ => None,
339336
}
340337
}

object/src/lib.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ pub use dicom_parser::error::{Error, Result};
4848
/// The default implementation of a root DICOM object.
4949
pub type DefaultDicomObject = RootDicomObject<mem::InMemDicomObject<StandardDataDictionary>>;
5050

51-
use std::fs::File;
52-
use std::io::{BufWriter, Write};
53-
use std::path::Path;
5451
use dicom_core::header::Header;
55-
use dicom_encoding::{transfer_syntax::TransferSyntaxIndex, text::SpecificCharacterSet};
52+
use dicom_encoding::{text::SpecificCharacterSet, transfer_syntax::TransferSyntaxIndex};
5653
use dicom_parser::dataset::{DataSetWriter, IntoTokens};
5754
use dicom_transfer_syntax_registry::TransferSyntaxRegistry;
55+
use std::fs::File;
56+
use std::io::{BufWriter, Write};
57+
use std::path::Path;
5858

5959
/// Trait type for a DICOM object.
6060
/// This is a high-level abstraction where an object is accessed and
@@ -118,7 +118,7 @@ where
118118

119119
// write meta group
120120
self.meta.write(&mut to)?;
121-
121+
122122
// prepare encoder
123123
let registry = TransferSyntaxRegistry::default();
124124
let ts = registry
@@ -197,23 +197,24 @@ where
197197

198198
#[cfg(test)]
199199
mod tests {
200-
use crate::RootDicomObject;
201200
use crate::meta::FileMetaTableBuilder;
201+
use crate::RootDicomObject;
202202

203203
#[test]
204204
fn smoke_test() {
205205
const FILE_NAME: &str = ".smoke-test.dcm";
206206

207207
let meta = FileMetaTableBuilder::new()
208-
.transfer_syntax(dicom_transfer_syntax_registry::entries::EXPLICIT_VR_LITTLE_ENDIAN.uid())
208+
.transfer_syntax(
209+
dicom_transfer_syntax_registry::entries::EXPLICIT_VR_LITTLE_ENDIAN.uid(),
210+
)
209211
.media_storage_sop_class_uid("1.2.840.10008.5.1.4.1.1.1")
210212
.media_storage_sop_instance_uid("1.2.3.456")
211213
.implementation_class_uid("1.2.345.6.7890.1.234")
212214
.build()
213215
.unwrap();
214-
let obj = RootDicomObject::new_empty_with_meta(
215-
meta);
216-
216+
let obj = RootDicomObject::new_empty_with_meta(meta);
217+
217218
obj.write_to_file(FILE_NAME).unwrap();
218219

219220
let obj2 = RootDicomObject::open_file(FILE_NAME).unwrap();

0 commit comments

Comments
 (0)