@@ -12,6 +12,7 @@ let kind = infer::get(&buf).expect("file type is known");
12
12
13
13
assert_eq!(kind.mime_type(), "image/jpeg");
14
14
assert_eq!(kind.extension(), "jpg");
15
+ assert_eq!(kind.matcher_type(), infer::MatcherType::Image);
15
16
```
16
17
17
18
### Check file type by path
@@ -129,6 +130,16 @@ impl Type {
129
130
}
130
131
131
132
/// Returns the type of matcher
133
+ ///
134
+ /// # Examples
135
+ ///
136
+ /// ```rust
137
+ /// let info = infer::Infer::new();
138
+ /// let buf = [0xFF, 0xD8, 0xFF, 0xAA];
139
+ /// let kind = info.get(&buf).expect("file type is known");
140
+ ///
141
+ /// assert_eq!(kind.matcher_type(), infer::MatcherType::Image);
142
+ /// ```
132
143
pub const fn matcher_type ( & self ) -> MatcherType {
133
144
self . matcher_type
134
145
}
@@ -613,6 +624,13 @@ mod tests {
613
624
assert_eq ! ( kind. mime_type( ) , "image/jpeg" ) ;
614
625
}
615
626
627
+ #[ test]
628
+ fn test_matcher_type ( ) {
629
+ let buf = [ 0xFF , 0xD8 , 0xFF , 0xAA ] ;
630
+ let kind = crate :: get ( & buf) . expect ( "file type is known" ) ;
631
+ assert_eq ! ( kind. matcher_type( ) , crate :: MatcherType :: Image ) ;
632
+ }
633
+
616
634
#[ cfg( feature = "alloc" ) ]
617
635
#[ test]
618
636
fn test_custom_matcher_ordering ( ) {
0 commit comments