Implement FileReader.{readAsText,readAsDataUrl}. Fixes #6172

This commit is contained in:
farodin91 2015-07-23 22:33:51 +02:00
parent f44d75e5b2
commit 27e760e28d
20 changed files with 565 additions and 326 deletions

View file

@ -9,6 +9,8 @@ use dom::bindings::utils::{Reflector, reflect_dom_object};
use dom::bindings::error::Fallible;
use dom::bindings::codegen::Bindings::BlobBinding;
use dom::bindings::codegen::Bindings::BlobBinding::BlobMethods;
use std::sync::mpsc;
use std::sync::mpsc::Receiver;
use util::str::DOMString;
@ -79,6 +81,22 @@ impl Blob {
}
}
pub trait BlobHelpers {
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> ;
fn read_out_type(self) -> DOMString;
}
impl<'a> BlobHelpers for &'a Blob {
fn read_out_buffer(self) -> Receiver<Option<Vec<u8>>> {
let (send, recv) = mpsc::channel();
send.send(self.bytes.clone()).unwrap();
recv
}
fn read_out_type(self) -> DOMString {
self.typeString.clone()
}
}
impl<'a> BlobMethods for &'a Blob {
// http://dev.w3.org/2006/webapi/FileAPI/#dfn-size
fn Size(self) -> u64{