async fn download_async(view: &JsPerspectiveView) -> Result<(), JsValue> {
    let csv_fut = view.to_csv(js_object!("formatted", true));
    let window = web_sys::window().unwrap();
    let document = window.document().unwrap();
    let element: web_sys::HtmlElement = document.create_element("a")?.unchecked_into();
    let blob_url = {
        let csv = csv_fut.await.unwrap();
        let csv_str = csv.as_string().unwrap();
        let bytes = csv_str.as_bytes();
        let array = unsafe { [Uint8Array::view(bytes)].iter().collect::<Array>() };
        let blob = web_sys::Blob::new_with_u8_array_sequence(&array)?;
        web_sys::Url::create_object_url_with_blob(&blob)?
    };

    element.set_attribute("download", "perspective.csv")?;
    element.set_attribute("href", &blob_url)?;
    element.style().set_property("display", "none")?;
    document.body().unwrap().append_child(&element)?;
    element.click();
    document.body().unwrap().remove_child(&element)?;
    Ok(())
}
/// Download a CSV, but not a `Promise`.  Used to implement the public methods.
Download a CSV, but not a `Promise`.  Used to implement the public methods.
Download a CSV but not a ` Promise ` . Used to implement the public methods .
async fn download_async(view: &JsPerspectiveView) -> Result<(), JsValue> {
    let csv_fut = view.to_csv(js_object!("formatted", true));
    let window = web_sys::window().unwrap();
    let document = window.document().unwrap();
    let element: web_sys::HtmlElement = document.create_element("a")?.unchecked_into();
    let blob_url = {
        let csv = csv_fut.await.unwrap();
        let csv_str = csv.as_string().unwrap();
        let bytes = csv_str.as_bytes();
        let array = unsafe { [Uint8Array::view(bytes)].iter().collect::<Array>() };
        let blob = web_sys::Blob::new_with_u8_array_sequence(&array)?;
        web_sys::Url::create_object_url_with_blob(&blob)?
    };
    element.set_attribute("download", "perspective.csv")?;
    element.set_attribute("href", &blob_url)?;
    element.style().set_property("display", "none")?;
    document.body().unwrap().append_child(&element)?;
    element.click();
    document.body().unwrap().remove_child(&element)?;
    Ok(())
}
async fn download_async ( view : & JsPerspectiveView ) -> Result < ( ) , JsValue > { let csv_fut = view . to_csv ( js_object ! ( " " true ) ) ; let window = web_sys :: window ( ) . unwrap ( ) ; let document = window . document ( ) . unwrap ( ) ; let element : web_sys :: HtmlElement = document . create_element ( " " ) ? . unchecked_into ( ) ; let blob_url = { let csv = csv_fut . await . unwrap ( ) ; let csv_str = csv . as_string ( ) . unwrap ( ) ; let bytes = csv_str . as_bytes ( ) ; let array = unsafe { [ Uint8Array :: view ( bytes ) ] . iter ( ) . collect :: < Array > ( ) } ; let blob = web_sys :: Blob :: new_with_u8_array_sequence ( & array ) ? ; web_sys :: Url :: create_object_url_with_blob ( & blob ) ? } ; element . set_attribute ( " " , " " ) ? ; element . set_attribute ( " " , & blob_url ) ? ; element . style ( ) . set_property ( " " , " " ) ? ; document . body ( ) . unwrap ( ) . append_child ( & element ) ? ; element . click ( ) ; document . body ( ) . unwrap ( ) . remove_child ( & element ) ? ; Ok ( ( ) ) }
Download a CSV, but not a `Promise`.
Download a CSV but not a ` Promise ` .
view
&JsPerspectiveView
view
&JsPerspectiveView