mirl 9.2.0

Miners Rust Lib - A massive collection of ever growing and changing functions, structs, and enums. Check the description for compatibility and toggleable features! (Most of the lib is controlled by flags/features so the lib can continue to be lightweight despite its size)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
#[cfg_attr(all(feature = "strum"), derive(strum::EnumIter))]
#[cfg_attr(all(feature = "enum_ext"), enum_ext::enum_extend)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "bitcode", derive(bitcode::Encode, bitcode::Decode))]
// #[cfg_attr(feature = "wincode", derive(wincode::SchemaWrite, wincode::SchemaRead))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Hash, PartialOrd, Ord)]
/// Key code to be interpreted anywhere
#[allow(missing_docs)]
#[cfg_attr(feature = "c_compatible", repr(C))]
pub enum KeyCode {
    // Letters
    A,
    B,
    C,
    D,
    E,
    F,
    G,
    H,
    I,
    J,
    K,
    L,
    M,
    N,
    O,
    P,
    Q,
    R,
    S,
    T,
    U,
    V,
    W,
    X,
    Y,
    Z,

    // Numbers
    Num0,
    Num1,
    Num2,
    Num3,
    Num4,
    Num5,
    Num6,
    Num7,
    Num8,
    Num9,
    KeyPad0,
    KeyPad1,
    KeyPad2,
    KeyPad3,
    KeyPad4,
    KeyPad5,
    KeyPad6,
    KeyPad7,
    KeyPad8,
    KeyPad9,

    // Function Keys
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    F11,
    F12,
    F13,
    F14,
    F15,
    F16,
    F17,
    F18,
    F19,
    F20,
    F21,
    F22,
    F23,
    F24,

    // Modifiers
    LeftShift,
    RightShift,
    LeftControl,
    RightControl,
    LeftAlt,
    RightAlt,
    LeftSuper,
    RightSuper,
    LeftHyper,
    RightHyper,
    AltControl,

    // Symbols / Punctuation
    Space,
    Enter,
    Escape,
    Backspace,
    Tab,
    BackTab,
    Comma,
    Period,
    Minus,
    Equal,
    LeftBracket,
    RightBracket,
    Backslash,
    Semicolon,
    Quote,
    Tilde,
    Slash,
    Grave,
    Apostrophe,

    // Arrow keys
    UpArrow,
    DownArrow,
    LeftArrow,
    RightArrow,

    // Editing keys
    Insert,
    Delete,
    Home,
    End,
    PageUp,
    PageDown,

    // Lock keys
    CapsLock,
    NumLock,
    ScrollLock,

    // Keypad operations
    KeyPadDivide,
    KeyPadMultiply,
    KeyPadSubtract,
    KeyPadAdd,
    KeyPadDecimal,
    KeyPadEnter,

    // International & special characters
    AUmlautÄ,
    UUmlautÜ,
    OUmlautÖ,
    SS,
    ACircumflexÂ,
    UAcuteÚ,
    OCircumflexÔ,
    ICircumflexÎ,
    ECircumflexÊ,
    EthÐ,
    OELigatureŒ,
    AAcuteÁ,
    YAcuteÝ,
    IUmlautÏ,
    NTildeÑ,
    OGraveÒ,
    UGraveÙ,
    ARingÅ,
    AELigatureÆ,
    OSlashØ,
    IGraveÌ,
    ThornÞ,

    // Multimedia keys
    // TODO: when checking for MediaPlayPause, also check MediaPlay and MediaPause
    MediaPlayPause,
    MediaPlay,
    MediaPause,
    MediaStop,
    MediaNext,
    MediaPrev,
    VolumeUp,
    VolumeDown,
    Mute,
    MediaReverse,
    MediaFastForward,
    MediaRecord,

    // Browser/OS keys
    BrowserBack,
    BrowserForward,
    BrowserRefresh,
    BrowserHome,
    LaunchMail,
    LaunchApp1,
    LaunchApp2,

    // Platform-specific
    Menu,
    PrintScreen,
    Pause,
    Application,

    // Convenient
    AnyShift,
    AnyAlt,
    AnyControl,
    AnySuper,

    // what
    F25,
    KeyPadEqual,
    World1,
    World2,
    SpecialControl,
    #[default]
    Unknown,
}

macro_rules! define_keys {
    ( $( $ident:ident => $name:expr ),* $(,)? ) => {
        // compile_error!("Hi");
         impl KeyCode {
            /// Converts the requested key to a string representation of itself
            #[must_use]
            pub const fn to_string(&self) -> &'static str {
                match self {
                    $( Self::$ident => $name ),*
                }
            }
            /// Converts the requested key to a string representation of itself
            #[must_use]
            pub fn str_to_keycode(string: &str) -> Self {
                match string {
                    $( $name => Self::$ident ),*,
                    _=>Self::Unknown
                }
            }
            #[must_use]
            #[cfg(feature = "std")]
            /// Converts self to `[Vec<Self>]`
            pub fn to_vec(&self) -> Vec<Self> {
                Vec::from([*self])
            }
        /// All available keys in string forming in a list
        pub const AVAILABLE_KEY_NAMES: &[&str] = &[
            $( $name ),*
        ];

        /// All available keys in [`KeyCode`] forming a list
        pub const AVAILABLE_KEYS: &[KeyCode] =&[
            $( KeyCode::$ident ),*];

        /// Get all available keys string form in a list
        #[must_use] pub const fn get_available_key_names() -> &'static [&'static str] {
            Self::AVAILABLE_KEY_NAMES
        }
        /// Get all available keys in [`KeyCode`] form in a list
        #[must_use] pub const fn get_available_keys() -> &'static [KeyCode] {
           Self::AVAILABLE_KEYS
        }
        }
        #[cfg(feature = "std")]
        impl StringToKeyCodes for String {
            fn to_keycodes(&self) -> Vec<KeyCode> {
                let mut list = Vec::new();
                for i in self.chars() {
                    list.push(i.to_keycode())
                }
                list
            }
            fn to_keycode(&self)->KeyCode{
                KeyCode::str_to_keycode(self)


            }
        }#[cfg(feature = "std")]
        impl StringToKeyCodes for char {
            fn to_keycodes(&self) -> Vec<KeyCode> {
                Vec::from([self.to_keycode()])
            }
            fn to_keycode(&self)->KeyCode{
                KeyCode::str_to_keycode(&self.to_string())
            }
        }

    };
}

#[cfg(feature = "std")]
/// Convert from a string to a `Vec<KeyCode>`
pub const trait StringToKeyCodes {
    /// Convert from a string to a `Vec<KeyCode>`
    fn to_keycodes(&self) -> Vec<KeyCode>;
    /// Converts a single text instance into the corresponding `KeyCode`
    fn to_keycode(&self) -> KeyCode;
}

impl KeyCode {
    #[must_use]
    #[allow(clippy::too_many_lines)]
    /// Convert a keycode to a String -> Letters/Numbers return a String while function keys return None
    pub const fn to_user_friendly_string(&self) -> Option<&'static str> {
        match self {
            Self::A => Some("A"),
            Self::B => Some("B"),
            Self::C => Some("C"),
            Self::D => Some("D"),
            Self::E => Some("E"),
            Self::F => Some("F"),
            Self::G => Some("G"),
            Self::H => Some("H"),
            Self::I => Some("I"),
            Self::J => Some("J"),
            Self::K => Some("K"),
            Self::L => Some("L"),
            Self::M => Some("M"),
            Self::N => Some("N"),
            Self::O => Some("O"),
            Self::P => Some("P"),
            Self::Q => Some("Q"),
            Self::R => Some("R"),
            Self::S => Some("S"),
            Self::T => Some("T"),
            Self::U => Some("U"),
            Self::V => Some("V"),
            Self::W => Some("W"),
            Self::X => Some("X"),
            Self::Y => Some("Y"),
            Self::Z => Some("Z"),
            Self::Num0 | Self::KeyPad0 => Some("0"),
            Self::Num1 | Self::KeyPad1 => Some("1"),
            Self::Num2 | Self::KeyPad2 => Some("2"),
            Self::Num3 | Self::KeyPad3 => Some("3"),
            Self::Num4 | Self::KeyPad4 => Some("4"),
            Self::Num5 | Self::KeyPad5 => Some("5"),
            Self::Num6 | Self::KeyPad6 => Some("6"),
            Self::Num7 | Self::KeyPad7 => Some("7"),
            Self::Num8 | Self::KeyPad8 => Some("8"),
            Self::Num9 | Self::KeyPad9 => Some("9"),
            Self::F1
            | Self::F2
            | Self::F3
            | Self::F4
            | Self::F5
            | Self::F6
            | Self::F7
            | Self::F8
            | Self::F9
            | Self::F10
            | Self::F11
            | Self::F12
            | Self::F13
            | Self::F14
            | Self::F15
            | Self::F16
            | Self::F17
            | Self::F18
            | Self::F19
            | Self::F20
            | Self::F21
            | Self::F22
            | Self::F23
            | Self::F24
            | Self::F25
            | Self::LeftShift
            | Self::RightShift
            | Self::LeftControl
            | Self::RightControl
            | Self::LeftAlt
            | Self::RightAlt
            | Self::LeftSuper
            | Self::RightSuper
            | Self::Escape
            | Self::Backspace
            | Self::UpArrow
            | Self::DownArrow
            | Self::LeftArrow
            | Self::RightArrow
            | Self::Insert
            | Self::Delete
            | Self::Home
            | Self::End
            | Self::PageUp
            | Self::PageDown
            | Self::CapsLock
            | Self::NumLock
            | Self::ScrollLock
            | Self::MediaPlayPause
            | Self::MediaStop
            | Self::MediaNext
            | Self::MediaPrev
            | Self::VolumeUp
            | Self::VolumeDown
            | Self::Mute
            | Self::BrowserBack
            | Self::BrowserForward
            | Self::BrowserRefresh
            | Self::BrowserHome
            | Self::LaunchMail
            | Self::LaunchApp1
            | Self::LaunchApp2
            | Self::Menu
            | Self::PrintScreen
            | Self::Pause
            | Self::Application
            | Self::World1
            | Self::World2
            | Self::AnyAlt
            | Self::AnySuper
            | Self::AnyControl
            | Self::AnyShift
            | Self::Unknown
            | Self::Enter
            | Self::KeyPadEnter
            | Self::BackTab
            | Self::Tab
            | Self::LeftHyper
            | Self::RightHyper
            | Self::AltControl
            | Self::MediaPlay
            | Self::MediaPause
            | Self::MediaReverse
            | Self::MediaFastForward
            | Self::MediaRecord
            | Self::SpecialControl => None,
            Self::Space => Some(" "),
            Self::Comma => Some(","),
            Self::Period | Self::KeyPadDecimal => Some("."),
            Self::Minus | Self::KeyPadSubtract => Some("-"),
            Self::Equal | Self::KeyPadEqual => Some("="),
            Self::LeftBracket => Some("["),
            Self::RightBracket => Some("]"),
            Self::Backslash => Some("\\"),
            Self::Semicolon => Some(";"),
            Self::Quote => Some("\""),
            Self::Tilde => Some("~"),
            Self::Slash | Self::KeyPadDivide => Some("/"),
            Self::Grave => Some("`"),
            Self::Apostrophe => Some("'"),
            Self::KeyPadMultiply => Some("*"),
            Self::KeyPadAdd => Some("+"),
            Self::AUmlautÄ => Some("Ä"),
            Self::UUmlautÜ => Some("Ü"),
            Self::OUmlautÖ => Some("Ö"),
            Self::SS => Some("ß"),
            Self::ACircumflex => Some("Â"),
            Self::UAcuteÚ => Some("Ú"),
            Self::OCircumflexÔ => Some("Ô"),
            Self::ICircumflexÎ => Some("Î"),
            Self::ECircumflexÊ => Some("Ê"),
            Self::EthÐ => Some("Ð"),
            Self::OELigatureŒ => Some("Œ"),
            Self::AAcuteÁ => Some("Á"),
            Self::YAcuteÝ => Some("Ý"),
            Self::IUmlautÏ => Some("Ï"),
            Self::NTildeÑ => Some("Ñ"),
            Self::OGraveÒ => Some("Ò"),
            Self::UGraveÙ => Some("Ù"),
            Self::ARingÅ => Some("Å"),
            Self::AELigatureÆ => Some("Æ"),
            Self::OSlashØ => Some("Ø"),
            Self::IGraveÌ => Some("Ì"),
            Self::ThornÞ => Some("Þ"),
        }
    }
}
#[cfg(feature = "std")]
impl core::fmt::Display for KeyCode {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        let value = self.to_string();
        write!(f, "{value}")
    }
}

define_keys!(
            // Letters
            A => "A",
            B => "B",
            C => "C",
            D => "D",
            E => "E",
            F => "F",
            G => "G",
            H => "H",
            I => "I",
            J => "J",
            K => "K",
            L => "L",
            M => "M",
            N => "N",
            O => "O",
            P => "P",
            Q => "Q",
            R => "R",
            S => "S",
            T => "T",
            U => "U",
            V => "V",
            W => "W",
            X => "X",
            Y => "Y",
            Z => "Z",

            // Numbers
            Num0 => "0",
            Num1 => "1",
            Num2 => "2",
            Num3 => "3",
            Num4 => "4",
            Num5 => "5",
            Num6 => "6",
            Num7 => "7",
            Num8 => "8",
            Num9 => "9",
            KeyPad0 => "KeyPad 0",
            KeyPad1 => "KeyPad 1",
            KeyPad2 => "KeyPad 2",
            KeyPad3 => "KeyPad 3",
            KeyPad4 => "KeyPad 4",
            KeyPad5 => "KeyPad 5",
            KeyPad6 => "KeyPad 6",
            KeyPad7 => "KeyPad 7",
            KeyPad8 => "KeyPad 8",
            KeyPad9 => "KeyPad 9",

            // Function Keys
            F1 => "F1",
            F2 => "F2",
            F3 => "F3",
            F4 => "F4",
            F5 => "F5",
            F6 => "F6",
            F7 => "F7",
            F8 => "F8",
            F9 => "F9",
            F10 => "F10",
            F11 => "F11",
            F12 => "F12",
            F13 => "F13",
            F14 => "F14",
            F15 => "F15",
            F16 => "F16",
            F17 => "F17",
            F18 => "F18",
            F19 => "F19",
            F20 => "F20",
            F21 => "F21",
            F22 => "F22",
            F23 => "F23",
            F24 => "F24",

            // Modifiers
            LeftShift => "Left Shift",
            RightShift => "Right Shift",
            LeftControl => "Left Control",
            RightControl => "Right Control",
            LeftAlt => "Left Alt",
            RightAlt => "Right Alt",
            LeftSuper => "Left Super",
            RightSuper => "Right Super",
    LeftHyper=>"Hyper Left",
    RightHyper=>"Hyper Right",
    AltControl=>"Alt Control",

            // Symbols / Punctuation
            Space => "Space",
            Enter => "Enter",
            Escape => "Escape",
            Backspace => "Backspace",
            Tab => "Tab",
            Comma => ",",
            Period => ".",
            Minus => "-",
            Equal => "=",
            LeftBracket => "[",
            RightBracket => "]",
            Backslash => "\\",
            Semicolon => ";",
            Quote => "\"",
            Tilde => "~",
            Slash => "/",
            Grave => "`",
            Apostrophe => "'",

            // Arrow keys
            UpArrow => "Up",
            DownArrow => "Down",
            LeftArrow => "Left",
            RightArrow => "Right",

            // Editing keys
            Insert => "Insert",
            Delete => "Delete",
            Home => "Home",
            End => "End",
            PageUp => "Page Up",
            PageDown => "Page Down",

            // Lock keys
            CapsLock => "Caps Lock",
            NumLock => "Num Lock",
            ScrollLock => "Scroll Lock",

            // Keypad operations
            KeyPadDivide => "KeyPad /",
            KeyPadMultiply => "KeyPad *",
            KeyPadSubtract => "KeyPad -",
            KeyPadAdd => "KeyPad +",
            KeyPadDecimal => "KeyPad .",
            KeyPadEnter => "KeyPad Enter",

            // International & special characters
            AUmlautÄ => "Ä",
            UUmlautÜ => "Ü",
            OUmlautÖ => "Ö",
            SS => "ß",
            ACircumflex => "Â",
            UAcuteÚ => "Ú",
            OCircumflexÔ => "Ô",
            ICircumflexÎ => "Î",
            ECircumflexÊ => "Ê",
            EthÐ => "Ð",
            OELigatureŒ => "Œ",
            AAcuteÁ => "Á",
            YAcuteÝ => "Ý",
            IUmlautÏ => "Ï",
            NTildeÑ => "Ñ",
            OGraveÒ => "Ò",
            UGraveÙ => "Ù",
            ARingÅ => "Å",
            AELigatureÆ => "Æ",
            OSlashØ => "Ø",
            IGraveÌ => "Ì",
            ThornÞ => "Þ",

            // Multimedia keys
            MediaPlayPause => "Media Play/Pause",
            MediaStop => "Media Stop",
            MediaNext => "Media Next",
            MediaPrev => "Media Previous",
            VolumeUp => "Volume Up",
            VolumeDown => "Volume Down",
            Mute => "Mute",
            MediaPause=>"Media Pause",
            MediaPlay=>"Media Play",
            MediaReverse=>"Media Reverse",
            MediaFastForward=>"Media Fast forward",
            MediaRecord=>"Media Record",

            // Browser/OS keys
            BrowserBack => "Browser Back",
            BrowserForward => "Browser Forward",
            BrowserRefresh => "Browser Refresh",
            BrowserHome => "Browser Home",
            LaunchMail => "Launch Mail",
            LaunchApp1 => "Launch App 1",
            LaunchApp2 => "Launch App 2",

            // Platform-specific
            Menu => "Menu",
            PrintScreen => "Print Screen",
            Pause => "Pause",
            Application => "Application",

            AnyShift=>"Shift",
            AnyControl=>"Control",
            AnyAlt=>"Alt",
            AnySuper=>"Super",

            // what
            F25 => "F25",
            KeyPadEqual => "KeyPad =",
            World1 => "World 1",
            World2 => "World 2",
            BackTab=>"BackTab",
            SpecialControl=>"Special Control",
            Unknown => "Unknown",);

#[must_use]
#[cfg(feature = "std")]
/// Convert a list of keycodes into a String and return the ones that weren't convertible
pub fn keycodes_to_str(keycodes: &Vec<KeyCode>) -> (String, Vec<KeyCode>) {
    let mut functions = Vec::new();
    let mut output = String::new();
    for key_code in keycodes {
        let value = key_code.to_user_friendly_string();
        if let Some(key) = value {
            for l in key.chars() {
                output.push(l);
            }
        } else {
            functions.push(*key_code);
        }
    }
    (output, functions)
}
impl KeyCode {
    #[must_use]
    /// Get the number of the keycode if it is a number
    pub const fn get_number<
        T: crate::math::ConstOne
            + crate::math::ConstZero
            + crate::math::ConstNumbers128,
    >(
        &self,
    ) -> Option<T> {
        Some(match self {
            Self::Num0 => T::ZERO,
            Self::Num1 => T::ONE,
            Self::Num2 => T::CONST_2,
            Self::Num3 => T::CONST_3,
            Self::Num4 => T::CONST_4,
            Self::Num5 => T::CONST_5,
            Self::Num6 => T::CONST_6,
            Self::Num7 => T::CONST_7,
            Self::Num8 => T::CONST_8,
            Self::Num9 => T::CONST_9,
            _ => return None,
        })
    }
    #[must_use]
    /// Check if the given keycode is a number
    pub const fn is_number(&self) -> bool {
        self.get_number::<u8>().is_some()
    }
}