@@ -6,8 +6,8 @@ use std::io::{Read, Seek};
6
6
use lofty:: error:: ErrorKind ;
7
7
use lofty:: resolve:: FileResolver ;
8
8
use lofty:: {
9
- Accessor , AudioFile , FileProperties , FileType , ParseOptions , Tag , TagExt , TagType , TaggedFile ,
10
- TaggedFileExt ,
9
+ Accessor , AudioFile , FileProperties , FileType , GlobalOptions , ParseOptions , Tag , TagExt ,
10
+ TagType , TaggedFile , TaggedFileExt , WriteOptions ,
11
11
} ;
12
12
13
13
fn file_ref_save ( path : & str , expected_file_type : FileType ) {
@@ -33,7 +33,7 @@ fn file_ref_save(path: &str, expected_file_type: FileType) {
33
33
tag. set_comment ( String :: from ( "a comment" ) ) ;
34
34
tag. set_track ( 5 ) ;
35
35
tag. set_year ( 2020 ) ;
36
- tag. save_to ( & mut file) . unwrap ( ) ;
36
+ tag. save_to ( & mut file, WriteOptions :: default ( ) ) . unwrap ( ) ;
37
37
}
38
38
file. rewind ( ) . unwrap ( ) ;
39
39
{
@@ -55,7 +55,7 @@ fn file_ref_save(path: &str, expected_file_type: FileType) {
55
55
tag. set_comment ( String :: from ( "another comment" ) ) ;
56
56
tag. set_track ( 7 ) ;
57
57
tag. set_year ( 2080 ) ;
58
- tag. save_to ( & mut file) . unwrap ( ) ;
58
+ tag. save_to ( & mut file, WriteOptions :: default ( ) ) . unwrap ( ) ;
59
59
}
60
60
file. rewind ( ) . unwrap ( ) ;
61
61
{
@@ -214,72 +214,76 @@ fn test_default_file_extensions() {
214
214
// Marker test, Lofty does not replicate this API
215
215
}
216
216
217
- // TODO: We need to check resolvers *first* and then resort to our default implementations
218
- #[ test]
219
- #[ ignore]
220
- fn test_file_resolver ( ) {
221
- {
222
- let file = lofty:: read_from_path ( "tests/taglib/data/xing.mp3" ) . unwrap ( ) ;
223
- assert_eq ! ( file. file_type( ) , FileType :: Mpeg ) ;
224
- }
225
-
226
- struct DummyResolver ;
227
- impl Into < TaggedFile > for DummyResolver {
228
- fn into ( self ) -> TaggedFile {
229
- TaggedFile :: new ( FileType :: Vorbis , FileProperties :: default ( ) , Vec :: new ( ) )
230
- }
231
- }
217
+ use rusty_fork:: rusty_fork_test;
232
218
233
- impl AudioFile for DummyResolver {
234
- type Properties = ( ) ;
219
+ rusty_fork_test ! {
220
+ #[ test]
221
+ fn test_file_resolver( ) {
222
+ lofty:: apply_global_options( GlobalOptions :: new( ) . use_custom_resolvers( true ) ) ;
235
223
236
- fn read_from < R > ( _: & mut R , _: ParseOptions ) -> lofty:: Result < Self >
237
- where
238
- R : Read + Seek ,
239
- Self : Sized ,
240
224
{
241
- Ok ( Self )
225
+ let file = lofty:: read_from_path( "tests/taglib/data/xing.mp3" ) . unwrap( ) ;
226
+ assert_eq!( file. file_type( ) , FileType :: Mpeg ) ;
242
227
}
243
228
244
- fn save_to ( & self , _: & mut File ) -> lofty:: Result < ( ) > {
245
- unimplemented ! ( )
229
+ struct DummyResolver ;
230
+ impl Into <TaggedFile > for DummyResolver {
231
+ fn into( self ) -> TaggedFile {
232
+ TaggedFile :: new( FileType :: Vorbis , FileProperties :: default ( ) , Vec :: new( ) )
233
+ }
246
234
}
247
235
248
- fn properties ( & self ) -> & Self :: Properties {
249
- unimplemented ! ( )
250
- }
236
+ impl AudioFile for DummyResolver {
237
+ type Properties = ( ) ;
251
238
252
- fn contains_tag ( & self ) -> bool {
253
- unimplemented ! ( )
254
- }
239
+ fn read_from<R >( _: & mut R , _: ParseOptions ) -> lofty:: Result <Self >
240
+ where
241
+ R : Read + Seek ,
242
+ Self : Sized ,
243
+ {
244
+ Ok ( Self )
245
+ }
255
246
256
- fn contains_tag_type ( & self , _: TagType ) -> bool {
257
- unimplemented ! ( )
258
- }
259
- }
247
+ fn save_to( & self , _: & mut File , _: WriteOptions ) -> lofty:: Result <( ) > {
248
+ unimplemented!( )
249
+ }
260
250
261
- impl FileResolver for DummyResolver {
262
- fn extension ( ) -> Option < & ' static str > {
263
- Some ( "mp3" )
264
- }
251
+ fn properties( & self ) -> & Self :: Properties {
252
+ unimplemented!( )
253
+ }
265
254
266
- fn primary_tag_type ( ) -> TagType {
267
- unimplemented ! ( )
268
- }
255
+ fn contains_tag ( & self ) -> bool {
256
+ unimplemented!( )
257
+ }
269
258
270
- fn supported_tag_types ( ) -> & ' static [ TagType ] {
271
- unimplemented ! ( )
259
+ fn contains_tag_type( & self , _: TagType ) -> bool {
260
+ unimplemented!( )
261
+ }
272
262
}
273
263
274
- fn guess ( _: & [ u8 ] ) -> Option < FileType > {
275
- Some ( FileType :: Vorbis )
264
+ impl FileResolver for DummyResolver {
265
+ fn extension( ) -> Option <& ' static str > {
266
+ Some ( "mp3" )
267
+ }
268
+
269
+ fn primary_tag_type( ) -> TagType {
270
+ unimplemented!( )
271
+ }
272
+
273
+ fn supported_tag_types( ) -> & ' static [ TagType ] {
274
+ unimplemented!( )
275
+ }
276
+
277
+ fn guess( _: & [ u8 ] ) -> Option <FileType > {
278
+ Some ( FileType :: Vorbis )
279
+ }
276
280
}
277
- }
278
281
279
- lofty:: resolve:: register_custom_resolver :: < DummyResolver > ( "Dummy" ) ;
282
+ lofty:: resolve:: register_custom_resolver:: <DummyResolver >( "Dummy" ) ;
280
283
281
- {
282
- let file = lofty:: read_from_path ( "tests/taglib/data/xing.mp3" ) . unwrap ( ) ;
283
- assert_eq ! ( file. file_type( ) , FileType :: Vorbis ) ;
284
+ {
285
+ let file = lofty:: read_from_path( "tests/taglib/data/xing.mp3" ) . unwrap( ) ;
286
+ assert_eq!( file. file_type( ) , FileType :: Vorbis ) ;
287
+ }
284
288
}
285
289
}
0 commit comments