fn dump_button(root: &mut Cursive, gpt: Gpt, info: Info) {
    let mut view: FormatSelect = selection();
    for var in &Format::variants() {
        view.add_item(
            *var,
            Format::from_str(var).expect("Couldn't get variant from itself.."),
        )
    }
    view.set_on_submit(move |root: &mut Cursive, format: &Format| {
        let text = match dump(&gpt, *format, &info) {
            Ok(t) => {
                root.pop_layer();
                t
            }
            Err(e) => {
                root.add_layer(error(e).button("Cancel", |root| {
                    root.pop_layer();
                    root.pop_layer();
                }));
                return;
            }
        };
        let view = EditView::new()
            .on_submit(move |root, s| {
                match fs::write(Path::new(s), &text) {
                    Ok(_) => {
                        root.pop_layer();
                    }
                    Err(e) => root.add_layer(error(e)),
                }
                //
            })
            .min_width(20);
        let view = Dialog::around(view)
            .dismiss_button("Cancel")
            .title("Dump File")
            .title_position(HAlign::Left);
        root.add_layer(view);
    });
    let title = "Select format";
    root.add_layer(panel(title, view).min_width(title.len() + 6));
}
/// Dump the GPT Partition to a file
Dump the GPT Partition to a file
Dump the GPT Partition to a file
fn dump_button(root: &mut Cursive, gpt: Gpt, info: Info) {
    let mut view: FormatSelect = selection();
    for var in &Format::variants() {
        view.add_item(
            *var,
            Format::from_str(var).expect("Couldn't get variant from itself.."),
        )
    }
    view.set_on_submit(move |root: &mut Cursive, format: &Format| {
        let text = match dump(&gpt, *format, &info) {
            Ok(t) => {
                root.pop_layer();
                t
            }
            Err(e) => {
                root.add_layer(error(e).button("Cancel", |root| {
                    root.pop_layer();
                    root.pop_layer();
                }));
                return;
            }
        };
        let view = EditView::new()
            .on_submit(move |root, s| {
                match fs::write(Path::new(s), &text) {
                    Ok(_) => {
                        root.pop_layer();
                    }
                    Err(e) => root.add_layer(error(e)),
                }
                //
            })
            .min_width(20);
        let view = Dialog::around(view)
            .dismiss_button("Cancel")
            .title("Dump File")
            .title_position(HAlign::Left);
        root.add_layer(view);
    });
    let title = "Select format";
    root.add_layer(panel(title, view).min_width(title.len() + 6));
}
fn dump_button ( root : & mut Cursive , gpt : Gpt , info : Info ) { let mut view : FormatSelect = selection ( ) ; for var in & Format :: variants ( ) { view . add_item ( * var , Format :: from_str ( var ) . expect ( " " ) , ) } view . set_on_submit ( move | root : & mut Cursive , format : & Format | { let text = match dump ( & gpt , * format , & info ) { Ok ( t ) => { root . pop_layer ( ) ; t } Err ( e ) => { root . add_layer ( error ( e ) . button ( " " , | root | { root . pop_layer ( ) ; root . pop_layer ( ) ; } ) ) ; return ; } } ; let view = EditView :: new ( ) . on_submit ( move | root , s | { match fs :: write ( Path :: new ( s ) , & text ) { Ok ( _ ) => { root . pop_layer ( ) ; } Err ( e ) => root . add_layer ( error ( e ) ) , } // } ) . min_width ( 20 ) ; let view = Dialog :: around ( view ) . dismiss_button ( " " ) . title ( " " ) . title_position ( HAlign :: Left ) ; root . add_layer ( view ) ; } ) ; let title = " " ; root . add_layer ( panel ( title , view ) . min_width ( title . len ( ) + 6 ) ) ; }
Dump the GPT Partition to a file
Dump the GPT Partition to a file
root
&mut Cursive
gpt
Gpt
info
Info
root
&mut Cursive
gpt
Gpt
info
Info