diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-01-20 07:21:48 -0700 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-01-20 07:21:48 -0700 |
commit | 89645391bf42edd9977ed1b6f9b430ad786f209e (patch) | |
tree | daea1222ade1bc6a382685cb34550a605e9b6d75 | |
parent | 2d5b0e085571594e7da2ee519605dd6fac2caa54 (diff) | |
parent | cf0652812c3b5e7a8f57289d1257dc71b3bed3f2 (diff) | |
download | servo-89645391bf42edd9977ed1b6f9b430ad786f209e.tar.gz servo-89645391bf42edd9977ed1b6f9b430ad786f209e.zip |
auto merge of #4678 : Ms2ger/servo/doc-clone, r=jdm
-rw-r--r-- | components/script/dom/bindings/structuredclone.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/components/script/dom/bindings/structuredclone.rs b/components/script/dom/bindings/structuredclone.rs index f426c6f4677..85f813cda8b 100644 --- a/components/script/dom/bindings/structuredclone.rs +++ b/components/script/dom/bindings/structuredclone.rs @@ -2,6 +2,11 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +//! This module implements structured cloning, as defined by [HTML] +//! (https://html.spec.whatwg.org/multipage/#safe-passing-of-structured-data). + +#![deny(missing_docs)] + use dom::bindings::error::Fallible; use dom::bindings::error::Error::DataClone; use dom::bindings::global::GlobalRef; @@ -15,12 +20,14 @@ use js::jsval::{JSVal, UndefinedValue}; use libc::size_t; use std::ptr; +/// A buffer for a structured clone. pub struct StructuredCloneData { data: *mut u64, nbytes: size_t, } impl StructuredCloneData { + /// Writes a structured clone. Returns a `DataClone` error if that fails. pub fn write(cx: *mut JSContext, message: JSVal) -> Fallible<StructuredCloneData> { let mut data = ptr::null_mut(); @@ -39,6 +46,9 @@ impl StructuredCloneData { }) } + /// Reads a structured clone. + /// + /// Panics if `JS_ReadStructuredClone` fails. pub fn read(self, global: GlobalRef) -> JSVal { let mut message = UndefinedValue(); unsafe { |