Skip to main content

RecoveryOptions

Struct RecoveryOptions 

Source
pub struct RecoveryOptions {
Show 15 fields pub max_retries: u32, pub maximum_retry_exposure_seconds: f64, pub reconnect_delay_seconds: f64, pub command_timeout_seconds: f64, pub download_timeout_seconds: f64, pub exposure_grace_seconds: f64, pub cooling_timeout_seconds: f64, pub temperature_tolerance_c: f64, pub cooling_stable_samples: u32, pub cooling_sample_seconds: f64, pub ready_frame_download_retries: u32, pub direct_read_retries: u32, pub direct_read_chunk_kib: u32, pub usb_reset_after_failures: u32, pub usb_port_cycle: bool,
}

Fields§

§max_retries: u32§maximum_retry_exposure_seconds: f64§reconnect_delay_seconds: f64§command_timeout_seconds: f64§download_timeout_seconds: f64§exposure_grace_seconds: f64§cooling_timeout_seconds: f64§temperature_tolerance_c: f64§cooling_stable_samples: u32§cooling_sample_seconds: f64§ready_frame_download_retries: u32§direct_read_retries: u32§direct_read_chunk_kib: u32§usb_reset_after_failures: u32§usb_port_cycle: bool

Implementations§

Source§

impl RecoveryOptions

Source

pub fn fields() -> Vec<RecoveryField>

Examples found in repository?
examples/export_recovery.rs (line 9)
5fn managed_options() -> String {
6    let mut text = String::from(
7        "// Generated by regain-core export_recovery; edit recovery.rs instead.\nnamespace Regain.Core;\n\npublic sealed record RecoveryOptions\n{\n",
8    );
9    let fields = RecoveryOptions::fields();
10    for field in &fields {
11        let name = format!("{}{}", field.key[..1].to_uppercase(), &field.key[1..]);
12        let ty = match field.value_type {
13            RecoveryType::Integer(_, _) | RecoveryType::PowerOfTwo(_, _) => "int",
14            RecoveryType::Number { .. } => "double",
15            RecoveryType::Boolean => "bool",
16        };
17        writeln!(
18            text,
19            "    public {ty} {name} {{ get; init; }} = {};",
20            field.default
21        )
22        .unwrap();
23    }
24    text.push_str("    public void Validate()\n    {\n");
25    for field in fields {
26        let name = format!("{}{}", field.key[..1].to_uppercase(), &field.key[1..]);
27        let condition = match field.value_type {
28            RecoveryType::Integer(min, max) => format!("{name} < {min} || {name} > {max}"),
29            RecoveryType::PowerOfTwo(min, max) => {
30                format!("{name} < {min} || {name} > {max} || ({name} & ({name} - 1)) != 0")
31            }
32            RecoveryType::Number {
33                minimum,
34                exclusive,
35                maximum,
36            } => format!(
37                "double.IsNaN({name}) || double.IsInfinity({name}) || {name} {} {minimum} || {name} > {maximum}",
38                if exclusive { "<=" } else { "<" }
39            ),
40            RecoveryType::Boolean => continue,
41        };
42        writeln!(text, "        if ({condition})\n            throw new System.ArgumentOutOfRangeException(nameof({name}));").unwrap();
43    }
44    text.push_str("    }\n}\n");
45    text
46}
Source

pub fn validate(&self) -> Result<()>

Source

pub fn schema() -> Value

Strict hub/frontend schema without a schema/compiler dependency. Legacy profile loading intentionally still tolerates unknown keys.

Examples found in repository?
examples/export_recovery.rs (line 75)
63fn main() -> Result<(), Box<dyn Error>> {
64    let mut args = std::env::args().skip(1);
65    let contract = args
66        .next()
67        .ok_or("Usage: export_recovery CONTRACT MANAGED [--check]")?;
68    let managed = args
69        .next()
70        .ok_or("Usage: export_recovery CONTRACT MANAGED [--check]")?;
71    let option = args.next();
72    if option.as_deref().is_some_and(|s| s != "--check") || args.next().is_some() {
73        return Err("Unknown option".into());
74    }
75    let description = serde_json::json!({"contractVersion":1,"schema":RecoveryOptions::schema()});
76    save(
77        Path::new(&contract),
78        &(serde_json::to_string_pretty(&description)? + "\n"),
79        option.is_some(),
80    )?;
81    save(Path::new(&managed), &managed_options(), option.is_some())
82}
Source§

impl RecoveryOptions

Source

pub fn replacement_exposures(&self, microseconds: u64) -> u32

Same microsecond exposure and inclusive threshold used by core capture and every native outer supervisor. Rereads have separate eligibility.

Trait Implementations§

Source§

impl Clone for RecoveryOptions

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RecoveryOptions

Source§

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

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

impl Default for RecoveryOptions

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for RecoveryOptions

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for RecoveryOptions

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for RecoveryOptions

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for RecoveryOptions

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.