aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/blob.rs
diff options
context:
space:
mode:
authorMs2ger <Ms2ger@gmail.com>2015-11-17 16:52:17 +0100
committerMs2ger <Ms2ger@gmail.com>2015-11-18 11:14:05 +0100
commit0c61be7a577b99dc138eb6a2e46fb9276df0870d (patch)
tree8188a7ed8f86ce1fab95f7aa4ff5c43819e4520d /components/script/dom/blob.rs
parentceb72e54e469bb3811fb641e7c38f476781a5720 (diff)
downloadservo-0c61be7a577b99dc138eb6a2e46fb9276df0870d.tar.gz
servo-0c61be7a577b99dc138eb6a2e46fb9276df0870d.zip
Rustfmt some of script.
Diffstat (limited to 'components/script/dom/blob.rs')
-rw-r--r--components/script/dom/blob.rs31
1 files changed, 17 insertions, 14 deletions
diff --git a/components/script/dom/blob.rs b/components/script/dom/blob.rs
index c807fa58914..5e5c13516c4 100644
--- a/components/script/dom/blob.rs
+++ b/components/script/dom/blob.rs
@@ -11,7 +11,7 @@ use dom::bindings::reflector::{Reflector, reflect_dom_object};
use num::ToPrimitive;
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
-use std::cell::{Cell};
+use std::cell::Cell;
use std::cmp::{max, min};
use std::sync::mpsc::Sender;
use util::str::DOMString;
@@ -23,29 +23,27 @@ pub struct Blob {
bytes: Option<Vec<u8>>,
typeString: String,
global: GlobalField,
- isClosed_: Cell<bool>
+ isClosed_: Cell<bool>,
}
fn is_ascii_printable(string: &str) -> bool {
// Step 5.1 in Sec 5.1 of File API spec
// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
- string.chars().all(|c| { c >= '\x20' && c <= '\x7E' })
+ string.chars().all(|c| c >= '\x20' && c <= '\x7E')
}
impl Blob {
- pub fn new_inherited(global: GlobalRef,
- bytes: Option<Vec<u8>>, typeString: &str) -> Blob {
+ pub fn new_inherited(global: GlobalRef, bytes: Option<Vec<u8>>, typeString: &str) -> Blob {
Blob {
reflector_: Reflector::new(),
bytes: bytes,
typeString: typeString.to_owned(),
global: GlobalField::from_rooted(&global),
- isClosed_: Cell::new(false)
+ isClosed_: Cell::new(false),
}
}
- pub fn new(global: GlobalRef, bytes: Option<Vec<u8>>,
- typeString: &str) -> Root<Blob> {
+ pub fn new(global: GlobalRef, bytes: Option<Vec<u8>>, typeString: &str) -> Root<Blob> {
reflect_dom_object(box Blob::new_inherited(global, bytes, typeString),
global,
BlobBinding::Wrap)
@@ -57,9 +55,11 @@ impl Blob {
}
// http://dev.w3.org/2006/webapi/FileAPI/#constructorBlob
- pub fn Constructor_(global: GlobalRef, blobParts: DOMString,
- blobPropertyBag: &BlobBinding::BlobPropertyBag) -> Fallible<Root<Blob>> {
- //TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob
+ pub fn Constructor_(global: GlobalRef,
+ blobParts: DOMString,
+ blobPropertyBag: &BlobBinding::BlobPropertyBag)
+ -> Fallible<Root<Blob>> {
+ // TODO: accept other blobParts types - ArrayBuffer or ArrayBufferView or Blob
// FIXME(ajeffrey): convert directly from a DOMString to a Vec<u8>
let bytes: Option<Vec<u8>> = Some(String::from(blobParts).into_bytes());
let typeString = if is_ascii_printable(&blobPropertyBag.type_) {
@@ -85,7 +85,7 @@ impl BlobMethods for Blob {
fn Size(&self) -> u64 {
match self.bytes {
None => 0,
- Some(ref bytes) => bytes.len() as u64
+ Some(ref bytes) => bytes.len() as u64,
}
}
@@ -95,8 +95,11 @@ impl BlobMethods for Blob {
}
// https://dev.w3.org/2006/webapi/FileAPI/#slice-method-algo
- fn Slice(&self, start: Option<i64>, end: Option<i64>,
- contentType: Option<DOMString>) -> Root<Blob> {
+ fn Slice(&self,
+ start: Option<i64>,
+ end: Option<i64>,
+ contentType: Option<DOMString>)
+ -> Root<Blob> {
let size: i64 = self.Size().to_i64().unwrap();
let relativeStart: i64 = match start {
None => 0,