pub enum IsoDownloadState {
Init {
config: DownloadConfig,
},
WaitingForNetwork {
dhcp: DhcpState,
config: DownloadConfig,
},
Downloading {
http: HttpDownloadState,
network_config: DhcpConfig,
config: DownloadConfig,
disk_position: u64,
pending_write: usize,
bytes_written: usize,
},
Verifying {
result: DownloadResult,
expected_hash: [u8; 32],
verified_bytes: usize,
start_tsc: TscTimestamp,
},
Done {
result: DownloadResult,
},
Failed {
error: DownloadError,
},
}Expand description
ISO download orchestration state machine.
Coordinates DHCP → HTTP → Disk Write workflow.
Variants§
Init
Initial state with configuration.
Fields
config: DownloadConfigWaitingForNetwork
Waiting for DHCP to obtain network configuration.
Downloading
Network ready, downloading ISO.
Fields
http: HttpDownloadStateHTTP download state machine
network_config: DhcpConfigNetwork configuration from DHCP
config: DownloadConfigDownload configuration
Verifying
Download complete, verifying checksum (if hash provided).
Fields
result: DownloadResultDownload result so far
start_tsc: TscTimestampWhen verification started
Done
Download and verification complete.
Fields
result: DownloadResultFailed
Download failed.
Fields
error: DownloadErrorImplementations§
Source§impl IsoDownloadState
impl IsoDownloadState
Sourcepub fn new(config: DownloadConfig) -> Self
pub fn new(config: DownloadConfig) -> Self
Create new download state machine.
Sourcepub fn start(&mut self, existing_network: Option<DhcpConfig>, now_tsc: u64)
pub fn start(&mut self, existing_network: Option<DhcpConfig>, now_tsc: u64)
Start the download.
If already have network config, skip DHCP. Otherwise, start DHCP first.
Sourcepub fn step(
&mut self,
dhcp_event: Option<Result<DhcpConfig, ()>>,
dns_result: Result<Option<Ipv4Addr>, ()>,
tcp_state: TcpSocketState,
recv_data: Option<&[u8]>,
can_send: bool,
disk_write_result: Option<Result<usize, ()>>,
now_tsc: u64,
dhcp_timeout: u64,
dns_timeout: u64,
tcp_timeout: u64,
http_send_timeout: u64,
http_recv_timeout: u64,
) -> StepResult
pub fn step( &mut self, dhcp_event: Option<Result<DhcpConfig, ()>>, dns_result: Result<Option<Ipv4Addr>, ()>, tcp_state: TcpSocketState, recv_data: Option<&[u8]>, can_send: bool, disk_write_result: Option<Result<usize, ()>>, now_tsc: u64, dhcp_timeout: u64, dns_timeout: u64, tcp_timeout: u64, http_send_timeout: u64, http_recv_timeout: u64, ) -> StepResult
Step the state machine.
§Arguments
dhcp_event: DHCP event from smoltcp (if any)dns_result: DNS query result (if resolving)tcp_state: TCP socket state (if connected)recv_data: Data received from HTTP socketcan_send: Whether socket can senddisk_write_result: Result of disk write (Ok(written) or Err)now_tsc: Current TSC valuetimeouts: Timeout values
§Returns
StepResult indicating current status
Sourcefn step_inner(
&self,
current: IsoDownloadState,
dhcp_event: Option<Result<DhcpConfig, ()>>,
dns_result: Result<Option<Ipv4Addr>, ()>,
tcp_state: TcpSocketState,
recv_data: Option<&[u8]>,
can_send: bool,
disk_write_result: Option<Result<usize, ()>>,
now_tsc: u64,
dhcp_timeout: u64,
dns_timeout: u64,
tcp_timeout: u64,
http_send_timeout: u64,
http_recv_timeout: u64,
) -> (IsoDownloadState, StepResult)
fn step_inner( &self, current: IsoDownloadState, dhcp_event: Option<Result<DhcpConfig, ()>>, dns_result: Result<Option<Ipv4Addr>, ()>, tcp_state: TcpSocketState, recv_data: Option<&[u8]>, can_send: bool, disk_write_result: Option<Result<usize, ()>>, now_tsc: u64, dhcp_timeout: u64, dns_timeout: u64, tcp_timeout: u64, http_send_timeout: u64, http_recv_timeout: u64, ) -> (IsoDownloadState, StepResult)
Internal step implementation.
Sourcepub fn progress(&self) -> DownloadProgress
pub fn progress(&self) -> DownloadProgress
Get current progress.
Sourcepub fn result(&self) -> Option<&DownloadResult>
pub fn result(&self) -> Option<&DownloadResult>
Get download result (if complete).
Sourcepub fn error(&self) -> Option<&DownloadError>
pub fn error(&self) -> Option<&DownloadError>
Get error (if failed).
Sourcepub fn network_config(&self) -> Option<&DhcpConfig>
pub fn network_config(&self) -> Option<&DhcpConfig>
Get network config (if obtained).
Sourcepub fn socket_handle(&self) -> Option<usize>
pub fn socket_handle(&self) -> Option<usize>
Get HTTP socket handle (if downloading).
Sourcepub fn pending_send(&self) -> Option<(&[u8], usize)>
pub fn pending_send(&self) -> Option<(&[u8], usize)>
Get bytes to send (if in send phase).
Sourcepub fn pending_disk_write(&self) -> Option<(u64, usize)>
pub fn pending_disk_write(&self) -> Option<(u64, usize)>
Get data pending disk write.
Returns (current_sector, bytes_pending)
Sourcepub fn is_terminal(&self) -> bool
pub fn is_terminal(&self) -> bool
Check if download is complete (success or failure).