pub struct RoutingSnapshot { /* private fields */ }Expand description
Immutable discovery result, tied to an attachment and active configuration. Keeping a snapshot does not retain the host’s USB claims after Dac::close.
Implementations§
Source§impl RoutingSnapshot
impl RoutingSnapshot
Sourcepub fn hand_back_report(&self) -> Option<RoutingHandBackReport>
pub fn hand_back_report(&self) -> Option<RoutingHandBackReport>
None until final retirement completes; remains available after close.
Examples found in repository?
examples/usbip_lifecycle.rs (line 206)
148 fn full_uac3(
149 dac: Dac,
150 fd: i32,
151 caps: &usbdac_core::Capabilities,
152 volatile: bool,
153 ) -> Result<(), Box<dyn std::error::Error>> {
154 use usbdac_core::routing::{
155 ControlKey, Entity, RouteEdit, RouteValue, RoutingHandBackOutcome,
156 };
157 assert_eq!(caps.uac_version, UacVersion::V3);
158 assert_eq!(caps.link_speed, LinkSpeed::High);
159 let key = ControlKey::Selector(Entity {
160 interface: 0,
161 id: 8,
162 });
163 assert_eq!(power(fd)?, 2, "initial power must be D2");
164 let snapshot = dac.routing_discover_powered()?;
165 println!("UAC3_ROUTING snapshot={snapshot:?}");
166 assert_eq!(snapshot.configuration(), 3);
167 assert_eq!(power(fd)?, 2, "discovery must restore D2");
168 assert_eq!(
169 dac.routing_read_powered(&snapshot, key)?,
170 RouteValue::SelectorPin(1)
171 );
172 assert_eq!(power(fd)?, 2, "read must restore D2");
173 let report = dac.routing_apply_powered(
174 &snapshot,
175 &[RouteEdit {
176 key,
177 expected: RouteValue::SelectorPin(1),
178 value: RouteValue::SelectorPin(2),
179 }],
180 )?;
181 assert_eq!(report.changed, vec![key]);
182 let applied = out_of_band("snapshot")?;
183 assert!(
184 applied.contains("selector=[2]"),
185 "fixture selector was not written: {applied}"
186 );
187 assert!(
188 applied.contains(if volatile {
189 "selector_state=1"
190 } else {
191 "selector_state=2"
192 }),
193 "unexpected fixture selector after D2: {applied}"
194 );
195 assert_eq!(power(fd)?, 2, "apply must restore D2");
196 let updated = dac.routing_discover_powered()?;
197 assert_eq!(
198 dac.routing_read_powered(&updated, key)?,
199 RouteValue::SelectorPin(if volatile { 1 } else { 2 }),
200 "selector readback must reflect the fixture's D2 behavior"
201 );
202 assert_eq!(power(fd)?, 2);
203 dac.close()?;
204 assert!(Dac::await_usb_retirement(Duration::from_secs(3)));
205 let hand_back = snapshot
206 .hand_back_report()
207 .ok_or("missing routing hand-back report")?;
208 println!("UAC3_HAND_BACK {hand_back:?}");
209 if !volatile {
210 assert!(
211 hand_back
212 .controls
213 .contains(&(key, RoutingHandBackOutcome::Restored)),
214 "selector hand-back was not verified"
215 );
216 }
217 assert_eq!(power(fd)?, 2, "final power must be D2");
218 assert!(
219 out_of_band("snapshot")?.contains("selector_state=1"),
220 "fixture selector was not restored"
221 );
222 assert_eq!(alt(fd)?, 0);
223 for interface in [1, 0] {
224 claim(fd, interface, false)?;
225 }
226 println!("USBIP_LIFECYCLE_PASS mode=full-uac3 selector=restored power=D2 retired=true");
227 Ok(())
228 }pub fn diagnostics(&self) -> &[RoutingDiagnostic]
Sourcepub fn configuration(&self) -> u8
pub fn configuration(&self) -> u8
Examples found in repository?
examples/usbip_lifecycle.rs (line 166)
148 fn full_uac3(
149 dac: Dac,
150 fd: i32,
151 caps: &usbdac_core::Capabilities,
152 volatile: bool,
153 ) -> Result<(), Box<dyn std::error::Error>> {
154 use usbdac_core::routing::{
155 ControlKey, Entity, RouteEdit, RouteValue, RoutingHandBackOutcome,
156 };
157 assert_eq!(caps.uac_version, UacVersion::V3);
158 assert_eq!(caps.link_speed, LinkSpeed::High);
159 let key = ControlKey::Selector(Entity {
160 interface: 0,
161 id: 8,
162 });
163 assert_eq!(power(fd)?, 2, "initial power must be D2");
164 let snapshot = dac.routing_discover_powered()?;
165 println!("UAC3_ROUTING snapshot={snapshot:?}");
166 assert_eq!(snapshot.configuration(), 3);
167 assert_eq!(power(fd)?, 2, "discovery must restore D2");
168 assert_eq!(
169 dac.routing_read_powered(&snapshot, key)?,
170 RouteValue::SelectorPin(1)
171 );
172 assert_eq!(power(fd)?, 2, "read must restore D2");
173 let report = dac.routing_apply_powered(
174 &snapshot,
175 &[RouteEdit {
176 key,
177 expected: RouteValue::SelectorPin(1),
178 value: RouteValue::SelectorPin(2),
179 }],
180 )?;
181 assert_eq!(report.changed, vec![key]);
182 let applied = out_of_band("snapshot")?;
183 assert!(
184 applied.contains("selector=[2]"),
185 "fixture selector was not written: {applied}"
186 );
187 assert!(
188 applied.contains(if volatile {
189 "selector_state=1"
190 } else {
191 "selector_state=2"
192 }),
193 "unexpected fixture selector after D2: {applied}"
194 );
195 assert_eq!(power(fd)?, 2, "apply must restore D2");
196 let updated = dac.routing_discover_powered()?;
197 assert_eq!(
198 dac.routing_read_powered(&updated, key)?,
199 RouteValue::SelectorPin(if volatile { 1 } else { 2 }),
200 "selector readback must reflect the fixture's D2 behavior"
201 );
202 assert_eq!(power(fd)?, 2);
203 dac.close()?;
204 assert!(Dac::await_usb_retirement(Duration::from_secs(3)));
205 let hand_back = snapshot
206 .hand_back_report()
207 .ok_or("missing routing hand-back report")?;
208 println!("UAC3_HAND_BACK {hand_back:?}");
209 if !volatile {
210 assert!(
211 hand_back
212 .controls
213 .contains(&(key, RoutingHandBackOutcome::Restored)),
214 "selector hand-back was not verified"
215 );
216 }
217 assert_eq!(power(fd)?, 2, "final power must be D2");
218 assert!(
219 out_of_band("snapshot")?.contains("selector_state=1"),
220 "fixture selector was not restored"
221 );
222 assert_eq!(alt(fd)?, 0);
223 for interface in [1, 0] {
224 claim(fd, interface, false)?;
225 }
226 println!("USBIP_LIFECYCLE_PASS mode=full-uac3 selector=restored power=D2 retired=true");
227 Ok(())
228 }pub fn inventory(&self) -> &RoutingInventory
pub fn selector_values(&self) -> &[RouteChange]
Trait Implementations§
Source§impl Clone for RoutingSnapshot
impl Clone for RoutingSnapshot
Auto Trait Implementations§
impl !RefUnwindSafe for RoutingSnapshot
impl !UnwindSafe for RoutingSnapshot
impl Forget for RoutingSnapshot
impl Freeze for RoutingSnapshotwhere
*const ArcInner<OwnedUsbFd> is !null: Freeze,
PhantomData<ArcInner<OwnedUsbFd>>: Freeze,
*const ArcInner<[u8]> is !null: Freeze,
PhantomData<ArcInner<[u8]>>: Freeze,
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const LeafNode<Entity, RoutingUnit> is !null: Freeze,
PhantomData<(Owned, LeafOrInternal)>: Freeze,
PhantomData<Box<(Entity, RoutingUnit)>>: Freeze,
PhantomData<RouteChange>: Freeze,
*const LeafNode<(u8, u16), RoutingCluster> is !null: Freeze,
PhantomData<Box<((u8, u16), RoutingCluster)>>: Freeze,
PhantomData<RoutingDiagnostic>: Freeze,
*const ArcInner<Mutex<RawMutex, Option<RoutingHandBackReport>>> is !null: Freeze,
PhantomData<ArcInner<Mutex<RawMutex, Option<RoutingHandBackReport>>>>: Freeze,
impl Move for RoutingSnapshot
impl Send for RoutingSnapshotwhere
Arc<OwnedUsbFd>: Send,
Arc<[u8]>: Send,
RawVecInner: Send,
NodeRef<Owned, Entity, RoutingUnit, LeafOrInternal>: Send,
BoxRaw<(Entity, RoutingUnit)>: Send,
NodeRef<Owned, (u8, u16), RoutingCluster, LeafOrInternal>: Send,
BoxRaw<((u8, u16), RoutingCluster)>: Send,
Arc<Mutex<RawMutex, Option<RoutingHandBackReport>>>: Send,
impl Sync for RoutingSnapshotwhere
Arc<OwnedUsbFd>: Sync,
Arc<[u8]>: Sync,
RawVecInner: Sync,
NodeRef<Owned, Entity, RoutingUnit, LeafOrInternal>: Sync,
BoxRaw<(Entity, RoutingUnit)>: Sync,
NodeRef<Owned, (u8, u16), RoutingCluster, LeafOrInternal>: Sync,
BoxRaw<((u8, u16), RoutingCluster)>: Sync,
Arc<Mutex<RawMutex, Option<RoutingHandBackReport>>>: Sync,
impl Unpin for RoutingSnapshotwhere
Arc<OwnedUsbFd>: Unpin,
Arc<[u8]>: Unpin,
*const u8 is !null: Unpin,
*const LeafNode<Entity, RoutingUnit> is !null: Unpin,
Box<(Entity, RoutingUnit)>: Unpin,
*const LeafNode<(u8, u16), RoutingCluster> is !null: Unpin,
Box<((u8, u16), RoutingCluster)>: Unpin,
Arc<Mutex<RawMutex, Option<RoutingHandBackReport>>>: Unpin,
impl UnsafeUnpin for RoutingSnapshotwhere
*const ArcInner<OwnedUsbFd> is !null: UnsafeUnpin,
PhantomData<ArcInner<OwnedUsbFd>>: UnsafeUnpin,
*const ArcInner<[u8]> is !null: UnsafeUnpin,
PhantomData<ArcInner<[u8]>>: UnsafeUnpin,
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const LeafNode<Entity, RoutingUnit> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(Entity, RoutingUnit)>>: UnsafeUnpin,
PhantomData<RouteChange>: UnsafeUnpin,
*const LeafNode<(u8, u16), RoutingCluster> is !null: UnsafeUnpin,
PhantomData<Box<((u8, u16), RoutingCluster)>>: UnsafeUnpin,
PhantomData<RoutingDiagnostic>: UnsafeUnpin,
*const ArcInner<Mutex<RawMutex, Option<RoutingHandBackReport>>> is !null: UnsafeUnpin,
PhantomData<ArcInner<Mutex<RawMutex, Option<RoutingHandBackReport>>>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more