@@ -7,6 +7,7 @@ use std::fmt;
7
7
use std:: io:: { self , ErrorKind as IOErrorKind , Read } ;
8
8
use std:: mem;
9
9
use std:: path:: { Path , PathBuf } ;
10
+ use std:: sync:: Arc ;
10
11
11
12
use anyhow:: { Context , Result , anyhow, bail} ;
12
13
use tar:: EntryType ;
@@ -26,13 +27,13 @@ pub(crate) const VERSION_FILE: &str = "rust-installer-version";
26
27
27
28
pub trait Package : fmt:: Debug {
28
29
fn contains ( & self , component : & str , short_name : Option < & str > ) -> bool ;
29
- fn install < ' a > (
30
+ fn install (
30
31
& self ,
31
32
target : & Components ,
32
33
component : & str ,
33
34
short_name : Option < & str > ,
34
- tx : Transaction < ' a > ,
35
- ) -> Result < Transaction < ' a > > ;
35
+ tx : Transaction ,
36
+ ) -> Result < Transaction > ;
36
37
fn components ( & self ) -> Vec < String > ;
37
38
}
38
39
@@ -79,13 +80,13 @@ impl Package for DirectoryPackage {
79
80
false
80
81
}
81
82
}
82
- fn install < ' a > (
83
+ fn install (
83
84
& self ,
84
85
target : & Components ,
85
86
name : & str ,
86
87
short_name : Option < & str > ,
87
- tx : Transaction < ' a > ,
88
- ) -> Result < Transaction < ' a > > {
88
+ tx : Transaction ,
89
+ ) -> Result < Transaction > {
89
90
let actual_name = if self . components . contains ( name) {
90
91
name
91
92
} else if let Some ( n) = short_name {
@@ -137,13 +138,13 @@ impl Package for DirectoryPackage {
137
138
138
139
#[ derive( Debug ) ]
139
140
#[ allow( dead_code) ] // temp::Dir is held for drop.
140
- pub ( crate ) struct TarPackage < ' a > ( DirectoryPackage , temp:: Dir < ' a > ) ;
141
+ pub ( crate ) struct TarPackage ( DirectoryPackage , temp:: Dir ) ;
141
142
142
- impl < ' a > TarPackage < ' a > {
143
+ impl TarPackage {
143
144
pub ( crate ) fn new < R : Read > (
144
145
stream : R ,
145
- tmp_cx : & ' a temp:: Context ,
146
- notify_handler : Option < & ' a dyn Fn ( Notification < ' _ > ) > ,
146
+ tmp_cx : Arc < temp:: Context > ,
147
+ notify_handler : Option < & dyn Fn ( Notification < ' _ > ) > ,
147
148
process : & Process ,
148
149
) -> Result < Self > {
149
150
let temp_dir = tmp_cx. new_directory ( ) ?;
@@ -532,17 +533,17 @@ fn unpack_without_first_dir<R: Read>(
532
533
Ok ( ( ) )
533
534
}
534
535
535
- impl Package for TarPackage < ' _ > {
536
+ impl Package for TarPackage {
536
537
fn contains ( & self , component : & str , short_name : Option < & str > ) -> bool {
537
538
self . 0 . contains ( component, short_name)
538
539
}
539
- fn install < ' b > (
540
+ fn install (
540
541
& self ,
541
542
target : & Components ,
542
543
component : & str ,
543
544
short_name : Option < & str > ,
544
- tx : Transaction < ' b > ,
545
- ) -> Result < Transaction < ' b > > {
545
+ tx : Transaction ,
546
+ ) -> Result < Transaction > {
546
547
self . 0 . install ( target, component, short_name, tx)
547
548
}
548
549
fn components ( & self ) -> Vec < String > {
@@ -551,36 +552,36 @@ impl Package for TarPackage<'_> {
551
552
}
552
553
553
554
#[ derive( Debug ) ]
554
- pub ( crate ) struct TarGzPackage < ' a > ( TarPackage < ' a > ) ;
555
+ pub ( crate ) struct TarGzPackage ( TarPackage ) ;
555
556
556
- impl < ' a > TarGzPackage < ' a > {
557
+ impl TarGzPackage {
557
558
pub ( crate ) fn new < R : Read > (
558
559
stream : R ,
559
- tmp_cx : & ' a temp:: Context ,
560
- notify_handler : Option < & ' a dyn Fn ( Notification < ' _ > ) > ,
560
+ tmp_cx : Arc < temp:: Context > ,
561
+ notify_handler : Option < & dyn Fn ( Notification < ' _ > ) > ,
561
562
process : & Process ,
562
563
) -> Result < Self > {
563
564
let stream = flate2:: read:: GzDecoder :: new ( stream) ;
564
565
Ok ( TarGzPackage ( TarPackage :: new (
565
566
stream,
566
- tmp_cx,
567
+ Arc :: clone ( & tmp_cx) ,
567
568
notify_handler,
568
569
process,
569
570
) ?) )
570
571
}
571
572
}
572
573
573
- impl Package for TarGzPackage < ' _ > {
574
+ impl Package for TarGzPackage {
574
575
fn contains ( & self , component : & str , short_name : Option < & str > ) -> bool {
575
576
self . 0 . contains ( component, short_name)
576
577
}
577
- fn install < ' b > (
578
+ fn install (
578
579
& self ,
579
580
target : & Components ,
580
581
component : & str ,
581
582
short_name : Option < & str > ,
582
- tx : Transaction < ' b > ,
583
- ) -> Result < Transaction < ' b > > {
583
+ tx : Transaction ,
584
+ ) -> Result < Transaction > {
584
585
self . 0 . install ( target, component, short_name, tx)
585
586
}
586
587
fn components ( & self ) -> Vec < String > {
@@ -589,36 +590,36 @@ impl Package for TarGzPackage<'_> {
589
590
}
590
591
591
592
#[ derive( Debug ) ]
592
- pub ( crate ) struct TarXzPackage < ' a > ( TarPackage < ' a > ) ;
593
+ pub ( crate ) struct TarXzPackage ( TarPackage ) ;
593
594
594
- impl < ' a > TarXzPackage < ' a > {
595
+ impl TarXzPackage {
595
596
pub ( crate ) fn new < R : Read > (
596
597
stream : R ,
597
- tmp_cx : & ' a temp:: Context ,
598
- notify_handler : Option < & ' a dyn Fn ( Notification < ' _ > ) > ,
598
+ tmp_cx : Arc < temp:: Context > ,
599
+ notify_handler : Option < & dyn Fn ( Notification < ' _ > ) > ,
599
600
process : & Process ,
600
601
) -> Result < Self > {
601
602
let stream = xz2:: read:: XzDecoder :: new ( stream) ;
602
603
Ok ( TarXzPackage ( TarPackage :: new (
603
604
stream,
604
- tmp_cx,
605
+ Arc :: clone ( & tmp_cx) ,
605
606
notify_handler,
606
607
process,
607
608
) ?) )
608
609
}
609
610
}
610
611
611
- impl Package for TarXzPackage < ' _ > {
612
+ impl Package for TarXzPackage {
612
613
fn contains ( & self , component : & str , short_name : Option < & str > ) -> bool {
613
614
self . 0 . contains ( component, short_name)
614
615
}
615
- fn install < ' b > (
616
+ fn install (
616
617
& self ,
617
618
target : & Components ,
618
619
component : & str ,
619
620
short_name : Option < & str > ,
620
- tx : Transaction < ' b > ,
621
- ) -> Result < Transaction < ' b > > {
621
+ tx : Transaction ,
622
+ ) -> Result < Transaction > {
622
623
self . 0 . install ( target, component, short_name, tx)
623
624
}
624
625
fn components ( & self ) -> Vec < String > {
@@ -627,36 +628,36 @@ impl Package for TarXzPackage<'_> {
627
628
}
628
629
629
630
#[ derive( Debug ) ]
630
- pub ( crate ) struct TarZStdPackage < ' a > ( TarPackage < ' a > ) ;
631
+ pub ( crate ) struct TarZStdPackage ( TarPackage ) ;
631
632
632
- impl < ' a > TarZStdPackage < ' a > {
633
+ impl TarZStdPackage {
633
634
pub ( crate ) fn new < R : Read > (
634
635
stream : R ,
635
- tmp_cx : & ' a temp:: Context ,
636
- notify_handler : Option < & ' a dyn Fn ( Notification < ' _ > ) > ,
636
+ tmp_cx : Arc < temp:: Context > ,
637
+ notify_handler : Option < & dyn Fn ( Notification < ' _ > ) > ,
637
638
process : & Process ,
638
639
) -> Result < Self > {
639
640
let stream = zstd:: stream:: read:: Decoder :: new ( stream) ?;
640
641
Ok ( TarZStdPackage ( TarPackage :: new (
641
642
stream,
642
- tmp_cx,
643
+ Arc :: clone ( & tmp_cx) ,
643
644
notify_handler,
644
645
process,
645
646
) ?) )
646
647
}
647
648
}
648
649
649
- impl Package for TarZStdPackage < ' _ > {
650
+ impl Package for TarZStdPackage {
650
651
fn contains ( & self , component : & str , short_name : Option < & str > ) -> bool {
651
652
self . 0 . contains ( component, short_name)
652
653
}
653
- fn install < ' b > (
654
+ fn install (
654
655
& self ,
655
656
target : & Components ,
656
657
component : & str ,
657
658
short_name : Option < & str > ,
658
- tx : Transaction < ' b > ,
659
- ) -> Result < Transaction < ' b > > {
659
+ tx : Transaction ,
660
+ ) -> Result < Transaction > {
660
661
self . 0 . install ( target, component, short_name, tx)
661
662
}
662
663
fn components ( & self ) -> Vec < String > {
0 commit comments