@@ -25,20 +25,16 @@ use crate::{ContentType, Result};
2525pub struct Features ( pub ( crate ) Vec < i32 > ) ;
2626
2727/// Synchronous abstraction over file content.
28- pub trait SyncInput : SyncInputApi { }
29-
30- /// Asynchronous abstraction over file content.
31- pub trait AsyncInput : AsyncInputApi { }
32-
33- pub trait SyncInputApi {
28+ pub trait SyncInput {
3429 /// Returns the size of the input.
3530 fn length ( & self ) -> Result < u64 > ;
3631
3732 /// Reads from the input at the given offset to fill the buffer.
3833 fn read_at ( & mut self , buffer : & mut [ u8 ] , offset : u64 ) -> Result < ( ) > ;
3934}
4035
41- pub trait AsyncInputApi {
36+ /// Asynchronous abstraction over file content.
37+ pub trait AsyncInput {
4238 /// Returns the size of the input.
4339 fn length ( & self ) -> impl Future < Output = Result < u64 > > ;
4440
@@ -51,8 +47,7 @@ const _: () = const {
5147 assert ! ( std:: mem:: size_of:: <usize >( ) <= std:: mem:: size_of:: <u64 >( ) ) ;
5248} ;
5349
54- impl SyncInput for & [ u8 ] { }
55- impl SyncInputApi for & [ u8 ] {
50+ impl SyncInput for & [ u8 ] {
5651 fn length ( & self ) -> Result < u64 > {
5752 Ok ( self . len ( ) as u64 )
5853 }
@@ -64,8 +59,7 @@ impl SyncInputApi for &[u8] {
6459 }
6560}
6661
67- impl SyncInput for std:: fs:: File { }
68- impl SyncInputApi for std:: fs:: File {
62+ impl SyncInput for std:: fs:: File {
6963 fn length ( & self ) -> Result < u64 > {
7064 Ok ( self . metadata ( ) ?. len ( ) )
7165 }
@@ -76,18 +70,17 @@ impl SyncInputApi for std::fs::File {
7670 }
7771}
7872
79- impl < T : SyncInputApi > SyncInput for & mut T { }
80- impl < T : SyncInputApi > SyncInputApi for & mut T {
73+ impl < T : SyncInput > SyncInput for & mut T {
8174 fn length ( & self ) -> Result < u64 > {
82- <T as SyncInputApi >:: length ( self )
75+ <T as SyncInput >:: length ( self )
8376 }
8477
8578 fn read_at ( & mut self , buffer : & mut [ u8 ] , offset : u64 ) -> Result < ( ) > {
86- <T as SyncInputApi >:: read_at ( self , buffer, offset)
79+ <T as SyncInput >:: read_at ( self , buffer, offset)
8780 }
8881}
8982
90- impl < T : SyncInputApi > AsyncInputApi for T {
83+ impl < T : SyncInput > AsyncInput for T {
9184 fn length ( & self ) -> impl Future < Output = Result < u64 > > {
9285 std:: future:: ready ( self . length ( ) )
9386 }
@@ -97,8 +90,7 @@ impl<T: SyncInputApi> AsyncInputApi for T {
9790 }
9891}
9992
100- impl AsyncInput for tokio:: fs:: File { }
101- impl AsyncInputApi for tokio:: fs:: File {
93+ impl AsyncInput for tokio:: fs:: File {
10294 async fn length ( & self ) -> Result < u64 > {
10395 Ok ( self . metadata ( ) . await ?. len ( ) )
10496 }
@@ -134,7 +126,7 @@ impl FeaturesOrRuled {
134126 Self :: extract ( file) . await
135127 }
136128
137- pub ( crate ) async fn extract ( file : impl AsyncInputApi ) -> Result < Self > {
129+ pub ( crate ) async fn extract ( file : impl AsyncInput ) -> Result < Self > {
138130 let config = & crate :: model:: CONFIG ;
139131 let file_len = file. length ( ) . await ?;
140132 if file_len == 0 {
@@ -154,7 +146,7 @@ impl FeaturesOrRuled {
154146}
155147
156148async fn extract_features_async (
157- config : & ModelConfig , mut file : impl AsyncInputApi , file_len : u64 ,
149+ config : & ModelConfig , mut file : impl AsyncInput , file_len : u64 ,
158150) -> Result < ( Vec < u8 > , Vec < i32 > ) > {
159151 debug_assert ! ( config. beg_size < config. block_size) ;
160152 debug_assert ! ( config. end_size < config. block_size) ;
0 commit comments