@@ -13,7 +13,7 @@ extern crate fallible_collections;
13
13
extern crate num_traits;
14
14
use bitreader:: { BitReader , ReadInto } ;
15
15
use byteorder:: { ReadBytesExt , WriteBytesExt } ;
16
- use fallible_collections :: TryClone ;
16
+
17
17
use fallible_collections:: TryRead ;
18
18
use fallible_collections:: TryReserveError ;
19
19
use num_traits:: Num ;
@@ -1420,8 +1420,8 @@ fn read_avif_meta<T: Read + Offset>(src: &mut BMFFBox<T>) -> Result<AvifMeta> {
1420
1420
}
1421
1421
1422
1422
Ok ( AvifMeta {
1423
- properties : properties. unwrap_or_else ( TryVec :: new ) ,
1424
- item_references : item_references. unwrap_or_else ( TryVec :: new ) ,
1423
+ properties : properties. unwrap_or_default ( ) ,
1424
+ item_references : item_references. unwrap_or_default ( ) ,
1425
1425
primary_item_id,
1426
1426
iloc_items : iloc_items. ok_or ( Error :: InvalidData ( "iloc missing" ) ) ?,
1427
1427
} )
@@ -1562,7 +1562,7 @@ fn read_iref<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<SingleItemTypeRefer
1562
1562
fn read_iprp < T : Read > ( src : & mut BMFFBox < T > ) -> Result < TryVec < AssociatedProperty > > {
1563
1563
let mut iter = src. box_iter ( ) ;
1564
1564
1565
- let properties = match iter. next_box ( ) ? {
1565
+ let mut properties = match iter. next_box ( ) ? {
1566
1566
Some ( mut b) if b. head . name == BoxType :: ItemPropertyContainerBox => read_ipco ( & mut b) ,
1567
1567
Some ( _) => Err ( Error :: InvalidData ( "unexpected iprp child" ) ) ,
1568
1568
None => Err ( Error :: UnexpectedEOF ) ,
@@ -1571,7 +1571,7 @@ fn read_iprp<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<AssociatedProperty>
1571
1571
// Per HEIF (ISO 23008-12:2017) § 9.3.1: There can be zero or more ipma boxes
1572
1572
// but "There shall be at most one ItemPropertyAssociationbox with a given
1573
1573
// pair of values of version and flags"
1574
- let mut ipma_version_and_flag_values_seen = TryHashMap :: with_capacity ( 1 ) ?;
1574
+ let mut ipma_version_and_flag_values_seen = TryVec :: with_capacity ( 1 ) ?;
1575
1575
let mut associated = TryVec :: new ( ) ;
1576
1576
1577
1577
while let Some ( mut b) = iter. next_box ( ) ? {
@@ -1580,12 +1580,10 @@ fn read_iprp<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<AssociatedProperty>
1580
1580
}
1581
1581
1582
1582
let version_and_flags = read_fullbox_extra ( & mut b) ?;
1583
- if ipma_version_and_flag_values_seen
1584
- . insert ( version_and_flags, ( ) ) ?
1585
- . is_some ( )
1586
- {
1583
+ if ipma_version_and_flag_values_seen. contains ( & version_and_flags) {
1587
1584
return Err ( Error :: InvalidData ( "Duplicate ipma with same version/flags" ) ) ;
1588
1585
}
1586
+ ipma_version_and_flag_values_seen. push ( version_and_flags) ?;
1589
1587
let associations = read_ipma ( & mut b, version_and_flags) ?;
1590
1588
for a in associations {
1591
1589
if a. property_index == 0 {
@@ -1595,10 +1593,10 @@ fn read_iprp<T: Read>(src: &mut BMFFBox<T>) -> Result<TryVec<AssociatedProperty>
1595
1593
continue ;
1596
1594
}
1597
1595
1598
- if let Some ( prop ) = properties. get ( & a. property_index ) {
1596
+ if let Some ( property ) = properties. remove ( & a. property_index ) {
1599
1597
associated. push ( AssociatedProperty {
1600
1598
item_id : a. item_id ,
1601
- property : prop . try_clone ( ) ? ,
1599
+ property,
1602
1600
} ) ?;
1603
1601
}
1604
1602
}
@@ -1617,16 +1615,6 @@ pub enum ItemProperty {
1617
1615
Unsupported ,
1618
1616
}
1619
1617
1620
- impl TryClone for ItemProperty {
1621
- fn try_clone ( & self ) -> Result < Self , TryReserveError > {
1622
- Ok ( match self {
1623
- Self :: Channels ( val) => Self :: Channels ( val. try_clone ( ) ?) ,
1624
- Self :: AuxiliaryType ( val) => Self :: AuxiliaryType ( val. try_clone ( ) ?) ,
1625
- Self :: Unsupported => Self :: Unsupported ,
1626
- } )
1627
- }
1628
- }
1629
-
1630
1618
/// For storing ItemPropertyAssociation data
1631
1619
/// See HEIF (ISO 23008-12:2017) § 9.3.1
1632
1620
struct Association {
@@ -1726,15 +1714,6 @@ pub struct AuxiliaryTypeProperty {
1726
1714
aux_subtype : TryString ,
1727
1715
}
1728
1716
1729
- impl TryClone for AuxiliaryTypeProperty {
1730
- fn try_clone ( & self ) -> Result < Self , TryReserveError > {
1731
- Ok ( AuxiliaryTypeProperty {
1732
- aux_type : self . aux_type . try_clone ( ) ?,
1733
- aux_subtype : self . aux_subtype . try_clone ( ) ?,
1734
- } )
1735
- }
1736
- }
1737
-
1738
1717
/// Parse image properties for auxiliary images
1739
1718
/// See HEIF (ISO 23008-12:2017) § 6.5.8
1740
1719
fn read_auxc < T : Read > ( src : & mut BMFFBox < T > ) -> Result < AuxiliaryTypeProperty > {
0 commit comments