morpheus_network::state::download

Enum IsoDownloadState

Source
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

§

WaitingForNetwork

Waiting for DHCP to obtain network configuration.

Fields

§dhcp: DhcpState

DHCP state machine

§config: DownloadConfig

Download configuration

§

Downloading

Network ready, downloading ISO.

Fields

§http: HttpDownloadState

HTTP download state machine

§network_config: DhcpConfig

Network configuration from DHCP

§config: DownloadConfig

Download configuration

§disk_position: u64

Current disk write position (sectors)

§pending_write: usize

Bytes pending disk write

§bytes_written: usize

Total bytes written to disk

§

Verifying

Download complete, verifying checksum (if hash provided).

Fields

§result: DownloadResult

Download result so far

§expected_hash: [u8; 32]

Expected hash

§verified_bytes: usize

Verification progress (bytes checked)

§start_tsc: TscTimestamp

When verification started

§

Done

Download and verification complete.

Fields

§

Failed

Download failed.

Fields

Implementations§

Source§

impl IsoDownloadState

Source

pub fn new(config: DownloadConfig) -> Self

Create new download state machine.

Source

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.

Source

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 socket
  • can_send: Whether socket can send
  • disk_write_result: Result of disk write (Ok(written) or Err)
  • now_tsc: Current TSC value
  • timeouts: Timeout values
§Returns

StepResult indicating current status

Source

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.

Source

pub fn progress(&self) -> DownloadProgress

Get current progress.

Source

pub fn result(&self) -> Option<&DownloadResult>

Get download result (if complete).

Source

pub fn error(&self) -> Option<&DownloadError>

Get error (if failed).

Source

pub fn network_config(&self) -> Option<&DhcpConfig>

Get network config (if obtained).

Source

pub fn socket_handle(&self) -> Option<usize>

Get HTTP socket handle (if downloading).

Source

pub fn pending_send(&self) -> Option<(&[u8], usize)>

Get bytes to send (if in send phase).

Source

pub fn mark_sent(&mut self, bytes: usize)

Mark bytes as sent.

Source

pub fn pending_disk_write(&self) -> Option<(u64, usize)>

Get data pending disk write.

Returns (current_sector, bytes_pending)

Source

pub fn is_terminal(&self) -> bool

Check if download is complete (success or failure).

Source

pub fn is_active(&self) -> bool

Check if download is in progress.

Source

pub fn cancel(&mut self)

Cancel the download.

Trait Implementations§

Source§

impl Debug for IsoDownloadState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for IsoDownloadState

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.