@@ -19,14 +19,10 @@ use iroh::{NodeAddr, PublicKey, RelayUrl};
1919use tokio:: io:: AsyncWriteExt ;
2020
2121use crate :: {
22- get:: {
23- progress:: { BlobProgress , DownloadProgress } ,
24- Stats ,
25- } ,
26- provider:: AddProgress ,
22+ get:: Stats ,
2723 rpc:: client:: blobs:: {
28- self , BlobInfo , BlobStatus , CollectionInfo , DownloadMode , DownloadOptions ,
29- IncompleteBlobInfo , WrapOption ,
24+ self , AddProgressEvent , BlobInfo , BlobProgressEvent , BlobStatus , CollectionInfo ,
25+ DownloadMode , DownloadOptions , DownloadProgressEvent , IncompleteBlobInfo , WrapOption ,
3026 } ,
3127 store:: { ConsistencyCheckProgress , ExportFormat , ExportMode , ReportLevel , ValidateProgress } ,
3228 ticket:: BlobTicket ,
@@ -898,29 +894,29 @@ pub struct ProvideResponseEntry {
898894 pub hash : Hash ,
899895}
900896
901- /// Combines the [`AddProgress `] outputs from a [`Stream`] into a single tuple.
897+ /// Combines the [`AddProgressEvent `] outputs from a [`Stream`] into a single tuple.
902898pub async fn aggregate_add_response (
903- mut stream : impl Stream < Item = Result < AddProgress > > + Unpin ,
899+ mut stream : impl Stream < Item = Result < AddProgressEvent > > + Unpin ,
904900) -> Result < ( Hash , BlobFormat , Vec < ProvideResponseEntry > ) > {
905901 let mut hash_and_format = None ;
906902 let mut collections = BTreeMap :: < u64 , ( String , u64 , Option < Hash > ) > :: new ( ) ;
907903 let mut mp = Some ( ProvideProgressState :: new ( ) ) ;
908904 while let Some ( item) = stream. next ( ) . await {
909905 match item? {
910- AddProgress :: Found { name, id, size } => {
906+ AddProgressEvent :: Found { name, id, size } => {
911907 tracing:: trace!( "Found({id},{name},{size})" ) ;
912908 if let Some ( mp) = mp. as_mut ( ) {
913909 mp. found ( name. clone ( ) , id, size) ;
914910 }
915911 collections. insert ( id, ( name, size, None ) ) ;
916912 }
917- AddProgress :: Progress { id, offset } => {
913+ AddProgressEvent :: Progress { id, offset } => {
918914 tracing:: trace!( "Progress({id}, {offset})" ) ;
919915 if let Some ( mp) = mp. as_mut ( ) {
920916 mp. progress ( id, offset) ;
921917 }
922918 }
923- AddProgress :: Done { hash, id } => {
919+ AddProgressEvent :: Done { hash, id } => {
924920 tracing:: trace!( "Done({id},{hash:?})" ) ;
925921 if let Some ( mp) = mp. as_mut ( ) {
926922 mp. done ( id, hash) ;
@@ -934,15 +930,15 @@ pub async fn aggregate_add_response(
934930 }
935931 }
936932 }
937- AddProgress :: AllDone { hash, format, .. } => {
933+ AddProgressEvent :: AllDone { hash, format, .. } => {
938934 tracing:: trace!( "AllDone({hash:?})" ) ;
939935 if let Some ( mp) = mp. take ( ) {
940936 mp. all_done ( ) ;
941937 }
942938 hash_and_format = Some ( HashAndFormat { hash, format } ) ;
943939 break ;
944940 }
945- AddProgress :: Abort ( e) => {
941+ AddProgressEvent :: Abort ( e) => {
946942 if let Some ( mp) = mp. take ( ) {
947943 mp. error ( ) ;
948944 }
@@ -1035,7 +1031,7 @@ impl ProvideProgressState {
10351031/// Displays the download progress for a given stream.
10361032pub async fn show_download_progress (
10371033 hash : Hash ,
1038- mut stream : impl Stream < Item = Result < DownloadProgress > > + Unpin ,
1034+ mut stream : impl Stream < Item = Result < DownloadProgressEvent > > + Unpin ,
10391035) -> Result < ( ) > {
10401036 eprintln ! ( "Fetching: {}" , hash) ;
10411037 let mp = MultiProgress :: new ( ) ;
@@ -1046,7 +1042,7 @@ pub async fn show_download_progress(
10461042 let mut seq = false ;
10471043 while let Some ( x) = stream. next ( ) . await {
10481044 match x? {
1049- DownloadProgress :: InitialState ( state) => {
1045+ DownloadProgressEvent :: InitialState ( state) => {
10501046 if state. connected {
10511047 op. set_message ( format ! ( "{} Requesting ...\n " , style( "[2/3]" ) . bold( ) . dim( ) ) ) ;
10521048 }
@@ -1066,21 +1062,21 @@ pub async fn show_download_progress(
10661062 ip. set_length ( size. value ( ) ) ;
10671063 ip. reset ( ) ;
10681064 match blob. progress {
1069- BlobProgress :: Pending => { }
1070- BlobProgress :: Progressing ( offset) => ip. set_position ( offset) ,
1071- BlobProgress :: Done => ip. finish_and_clear ( ) ,
1065+ BlobProgressEvent :: Pending => { }
1066+ BlobProgressEvent :: Progressing ( offset) => ip. set_position ( offset) ,
1067+ BlobProgressEvent :: Done => ip. finish_and_clear ( ) ,
10721068 }
10731069 if !seq {
10741070 op. finish_and_clear ( ) ;
10751071 }
10761072 }
10771073 }
10781074 }
1079- DownloadProgress :: FoundLocal { .. } => { }
1080- DownloadProgress :: Connected => {
1075+ DownloadProgressEvent :: FoundLocal { .. } => { }
1076+ DownloadProgressEvent :: Connected => {
10811077 op. set_message ( format ! ( "{} Requesting ...\n " , style( "[2/3]" ) . bold( ) . dim( ) ) ) ;
10821078 }
1083- DownloadProgress :: FoundHashSeq { children, .. } => {
1079+ DownloadProgressEvent :: FoundHashSeq { children, .. } => {
10841080 op. set_message ( format ! (
10851081 "{} Downloading {} blob(s)\n " ,
10861082 style( "[3/3]" ) . bold( ) . dim( ) ,
@@ -1090,7 +1086,7 @@ pub async fn show_download_progress(
10901086 op. reset ( ) ;
10911087 seq = true ;
10921088 }
1093- DownloadProgress :: Found { size, child, .. } => {
1089+ DownloadProgressEvent :: Found { size, child, .. } => {
10941090 if seq {
10951091 op. set_position ( child. into ( ) ) ;
10961092 } else {
@@ -1099,13 +1095,13 @@ pub async fn show_download_progress(
10991095 ip. set_length ( size) ;
11001096 ip. reset ( ) ;
11011097 }
1102- DownloadProgress :: Progress { offset, .. } => {
1098+ DownloadProgressEvent :: Progress { offset, .. } => {
11031099 ip. set_position ( offset) ;
11041100 }
1105- DownloadProgress :: Done { .. } => {
1101+ DownloadProgressEvent :: Done { .. } => {
11061102 ip. finish_and_clear ( ) ;
11071103 }
1108- DownloadProgress :: AllDone ( Stats {
1104+ DownloadProgressEvent :: AllDone ( Stats {
11091105 bytes_read,
11101106 elapsed,
11111107 ..
@@ -1119,7 +1115,7 @@ pub async fn show_download_progress(
11191115 ) ;
11201116 break ;
11211117 }
1122- DownloadProgress :: Abort ( e) => {
1118+ DownloadProgressEvent :: Abort ( e) => {
11231119 bail ! ( "download aborted: {}" , e) ;
11241120 }
11251121 }
0 commit comments