44
55use core:: cmp;
66use managed:: { ManagedSlice , ManagedMap } ;
7- #[ cfg( not( feature = "proto-igmp" ) ) ]
8- use core:: marker:: PhantomData ;
97
108use crate :: { Error , Result } ;
119use crate :: phy:: { Device , DeviceCapabilities , RxToken , TxToken } ;
@@ -57,9 +55,9 @@ use crate::iface::Routes;
5755/// The network interface logically owns a number of other data structures; to avoid
5856/// a dependency on heap allocation, it instead owns a `BorrowMut<[T]>`, which can be
5957/// a `&mut [T]`, or `Vec<T>` if a heap is available.
60- pub struct Interface < ' b , ' c , ' e , DeviceT : for < ' d > Device < ' d > > {
58+ pub struct Interface < ' a , DeviceT : for < ' d > Device < ' d > > {
6159 device : DeviceT ,
62- inner : InterfaceInner < ' b , ' c , ' e > ,
60+ inner : InterfaceInner < ' a > ,
6361}
6462
6563/// The device independent part of an Ethernet network interface.
@@ -69,17 +67,15 @@ pub struct Interface<'b, 'c, 'e, DeviceT: for<'d> Device<'d>> {
6967/// the `device` mutably until they're used, which makes it impossible to call other
7068/// methods on the `Interface` in this time (since its `device` field is borrowed
7169/// exclusively). However, it is still possible to call methods on its `inner` field.
72- struct InterfaceInner < ' b , ' c , ' e > {
73- neighbor_cache : NeighborCache < ' b > ,
70+ struct InterfaceInner < ' a > {
71+ neighbor_cache : NeighborCache < ' a > ,
7472 ethernet_addr : EthernetAddress ,
75- ip_addrs : ManagedSlice < ' c , IpCidr > ,
73+ ip_addrs : ManagedSlice < ' a , IpCidr > ,
7674 #[ cfg( feature = "proto-ipv4" ) ]
7775 any_ip : bool ,
78- routes : Routes < ' e > ,
76+ routes : Routes < ' a > ,
7977 #[ cfg( feature = "proto-igmp" ) ]
80- ipv4_multicast_groups : ManagedMap < ' e , Ipv4Address , ( ) > ,
81- #[ cfg( not( feature = "proto-igmp" ) ) ]
82- _ipv4_multicast_groups : PhantomData < & ' e ( ) > ,
78+ ipv4_multicast_groups : ManagedMap < ' a , Ipv4Address , ( ) > ,
8379 /// When to report for (all or) the next multicast group membership via IGMP
8480 #[ cfg( feature = "proto-igmp" ) ]
8581 igmp_report_state : IgmpReportState ,
@@ -88,22 +84,20 @@ struct InterfaceInner<'b, 'c, 'e> {
8884
8985/// A builder structure used for creating a Ethernet network
9086/// interface.
91- pub struct InterfaceBuilder < ' b , ' c , ' e , DeviceT : for < ' d > Device < ' d > > {
87+ pub struct InterfaceBuilder < ' a , DeviceT : for < ' d > Device < ' d > > {
9288 device : DeviceT ,
9389 ethernet_addr : Option < EthernetAddress > ,
94- neighbor_cache : Option < NeighborCache < ' b > > ,
95- ip_addrs : ManagedSlice < ' c , IpCidr > ,
90+ neighbor_cache : Option < NeighborCache < ' a > > ,
91+ ip_addrs : ManagedSlice < ' a , IpCidr > ,
9692 #[ cfg( feature = "proto-ipv4" ) ]
9793 any_ip : bool ,
98- routes : Routes < ' e > ,
94+ routes : Routes < ' a > ,
9995 /// Does not share storage with `ipv6_multicast_groups` to avoid IPv6 size overhead.
10096 #[ cfg( feature = "proto-igmp" ) ]
101- ipv4_multicast_groups : ManagedMap < ' e , Ipv4Address , ( ) > ,
102- #[ cfg( not( feature = "proto-igmp" ) ) ]
103- _ipv4_multicast_groups : PhantomData < & ' e ( ) > ,
97+ ipv4_multicast_groups : ManagedMap < ' a , Ipv4Address , ( ) > ,
10498}
10599
106- impl < ' b , ' c , ' e , DeviceT > InterfaceBuilder < ' b , ' c , ' e , DeviceT >
100+ impl < ' a , DeviceT > InterfaceBuilder < ' a , DeviceT >
107101 where DeviceT : for < ' d > Device < ' d > {
108102 /// Create a builder used for creating a network interface using the
109103 /// given device and address.
@@ -141,8 +135,6 @@ impl<'b, 'c, 'e, DeviceT> InterfaceBuilder<'b, 'c, 'e, DeviceT>
141135 routes : Routes :: new ( ManagedMap :: Borrowed ( & mut [ ] ) ) ,
142136 #[ cfg( feature = "proto-igmp" ) ]
143137 ipv4_multicast_groups : ManagedMap :: Borrowed ( & mut [ ] ) ,
144- #[ cfg( not( feature = "proto-igmp" ) ) ]
145- _ipv4_multicast_groups : PhantomData ,
146138 }
147139 }
148140
@@ -167,7 +159,7 @@ impl<'b, 'c, 'e, DeviceT> InterfaceBuilder<'b, 'c, 'e, DeviceT>
167159 ///
168160 /// [ip_addrs]: struct.EthernetInterface.html#method.ip_addrs
169161 pub fn ip_addrs < T > ( mut self , ip_addrs : T ) -> Self
170- where T : Into < ManagedSlice < ' c , IpCidr > >
162+ where T : Into < ManagedSlice < ' a , IpCidr > >
171163 {
172164 let ip_addrs = ip_addrs. into ( ) ;
173165 InterfaceInner :: check_ip_addrs ( & ip_addrs) ;
@@ -198,8 +190,8 @@ impl<'b, 'c, 'e, DeviceT> InterfaceBuilder<'b, 'c, 'e, DeviceT>
198190 /// [routes].
199191 ///
200192 /// [routes]: struct.EthernetInterface.html#method.routes
201- pub fn routes < T > ( mut self , routes : T ) -> InterfaceBuilder < ' b , ' c , ' e , DeviceT >
202- where T : Into < Routes < ' e > >
193+ pub fn routes < T > ( mut self , routes : T ) -> InterfaceBuilder < ' a , DeviceT >
194+ where T : Into < Routes < ' a > >
203195 {
204196 self . routes = routes. into ( ) ;
205197 self
@@ -217,14 +209,14 @@ impl<'b, 'c, 'e, DeviceT> InterfaceBuilder<'b, 'c, 'e, DeviceT>
217209 /// [`join_multicast_group()`]: struct.EthernetInterface.html#method.join_multicast_group
218210 #[ cfg( feature = "proto-igmp" ) ]
219211 pub fn ipv4_multicast_groups < T > ( mut self , ipv4_multicast_groups : T ) -> Self
220- where T : Into < ManagedMap < ' e , Ipv4Address , ( ) > >
212+ where T : Into < ManagedMap < ' a , Ipv4Address , ( ) > >
221213 {
222214 self . ipv4_multicast_groups = ipv4_multicast_groups. into ( ) ;
223215 self
224216 }
225217
226218 /// Set the Neighbor Cache the interface will use.
227- pub fn neighbor_cache ( mut self , neighbor_cache : NeighborCache < ' b > ) -> Self {
219+ pub fn neighbor_cache ( mut self , neighbor_cache : NeighborCache < ' a > ) -> Self {
228220 self . neighbor_cache = Some ( neighbor_cache) ;
229221 self
230222 }
@@ -240,7 +232,7 @@ impl<'b, 'c, 'e, DeviceT> InterfaceBuilder<'b, 'c, 'e, DeviceT>
240232 ///
241233 /// [ethernet_addr]: #method.ethernet_addr
242234 /// [neighbor_cache]: #method.neighbor_cache
243- pub fn finalize ( self ) -> Interface < ' b , ' c , ' e , DeviceT > {
235+ pub fn finalize ( self ) -> Interface < ' a , DeviceT > {
244236 match ( self . ethernet_addr , self . neighbor_cache ) {
245237 ( Some ( ethernet_addr) , Some ( neighbor_cache) ) => {
246238 let device_capabilities = self . device . capabilities ( ) ;
@@ -255,8 +247,6 @@ impl<'b, 'c, 'e, DeviceT> InterfaceBuilder<'b, 'c, 'e, DeviceT>
255247 routes : self . routes ,
256248 #[ cfg( feature = "proto-igmp" ) ]
257249 ipv4_multicast_groups : self . ipv4_multicast_groups ,
258- #[ cfg( not( feature = "proto-igmp" ) ) ]
259- _ipv4_multicast_groups : PhantomData ,
260250 #[ cfg( feature = "proto-igmp" ) ]
261251 igmp_report_state : IgmpReportState :: Inactive ,
262252 }
@@ -385,7 +375,7 @@ enum IgmpReportState {
385375 } ,
386376}
387377
388- impl < ' b , ' c , ' e , DeviceT > Interface < ' b , ' c , ' e , DeviceT >
378+ impl < ' a , DeviceT > Interface < ' a , DeviceT >
389379 where DeviceT : for < ' d > Device < ' d > {
390380 /// Get the Ethernet address of the interface.
391381 pub fn ethernet_addr ( & self ) -> EthernetAddress {
@@ -495,7 +485,7 @@ impl<'b, 'c, 'e, DeviceT> Interface<'b, 'c, 'e, DeviceT>
495485 ///
496486 /// # Panics
497487 /// This function panics if any of the addresses are not unicast.
498- pub fn update_ip_addrs < F : FnOnce ( & mut ManagedSlice < ' c , IpCidr > ) > ( & mut self , f : F ) {
488+ pub fn update_ip_addrs < F : FnOnce ( & mut ManagedSlice < ' a , IpCidr > ) > ( & mut self , f : F ) {
499489 f ( & mut self . inner . ip_addrs ) ;
500490 InterfaceInner :: check_ip_addrs ( & self . inner . ip_addrs )
501491 }
@@ -511,11 +501,11 @@ impl<'b, 'c, 'e, DeviceT> Interface<'b, 'c, 'e, DeviceT>
511501 self . inner . ipv4_address ( )
512502 }
513503
514- pub fn routes ( & self ) -> & Routes < ' e > {
504+ pub fn routes ( & self ) -> & Routes < ' a > {
515505 & self . inner . routes
516506 }
517507
518- pub fn routes_mut ( & mut self ) -> & mut Routes < ' e > {
508+ pub fn routes_mut ( & mut self ) -> & mut Routes < ' a > {
519509 & mut self . inner . routes
520510 }
521511
@@ -752,7 +742,7 @@ impl<'b, 'c, 'e, DeviceT> Interface<'b, 'c, 'e, DeviceT>
752742 }
753743}
754744
755- impl < ' b , ' c , ' e > InterfaceInner < ' b , ' c , ' e > {
745+ impl < ' a > InterfaceInner < ' a > {
756746 fn check_ethernet_addr ( addr : & EthernetAddress ) {
757747 if addr. is_multicast ( ) {
758748 panic ! ( "Ethernet address {} is not unicast" , addr)
@@ -1730,8 +1720,7 @@ mod test {
17301720
17311721 use super :: { EthernetPacket , IpPacket } ;
17321722
1733- fn create_loopback < ' a , ' b , ' c > ( ) -> ( EthernetInterface < ' static , ' b , ' c , Loopback > ,
1734- SocketSet < ' static , ' a > ) {
1723+ fn create_loopback < ' a > ( ) -> ( EthernetInterface < ' a , Loopback > , SocketSet < ' a > ) {
17351724 // Create a basic device
17361725 let device = Loopback :: new ( ) ;
17371726 let ip_addrs = [
@@ -1757,7 +1746,7 @@ mod test {
17571746 }
17581747
17591748 #[ cfg( feature = "proto-igmp" ) ]
1760- fn recv_all < ' b > ( iface : & mut EthernetInterface < ' static , ' b , ' static , Loopback > , timestamp : Instant ) -> Vec < Vec < u8 > > {
1749+ fn recv_all ( iface : & mut EthernetInterface < ' _ , Loopback > , timestamp : Instant ) -> Vec < Vec < u8 > > {
17611750 let mut pkts = Vec :: new ( ) ;
17621751 while let Some ( ( rx, _tx) ) = iface. device . receive ( ) {
17631752 rx. consume ( timestamp, |pkt| {
@@ -2533,7 +2522,7 @@ mod test {
25332522 #[ test]
25342523 #[ cfg( feature = "proto-igmp" ) ]
25352524 fn test_handle_igmp ( ) {
2536- fn recv_igmp < ' b > ( mut iface : & mut EthernetInterface < ' static , ' b , ' static , Loopback > , timestamp : Instant ) -> Vec < ( Ipv4Repr , IgmpRepr ) > {
2525+ fn recv_igmp ( mut iface : & mut EthernetInterface < ' _ , Loopback > , timestamp : Instant ) -> Vec < ( Ipv4Repr , IgmpRepr ) > {
25372526 let checksum_caps = & iface. device . capabilities ( ) . checksum ;
25382527 recv_all ( & mut iface, timestamp)
25392528 . iter ( )
0 commit comments