pub fn decode(update: &JsValue) -> Result<Self, JsValue> {
        if update.is_string() {
            let js_str = update.as_string().into_jserror()?;
            let bytes = base64::decode(js_str).into_jserror()?;
            let mut decoder = ZlibDecoder::new(&*bytes);
            let mut decoded = vec![];
            decoder.read_to_end(&mut decoded).into_jserror()?;
            rmp_serde::from_slice(&decoded).into_jserror()
        } else if update.is_instance_of::<js_sys::ArrayBuffer>() {
            let uint8array = js_sys::Uint8Array::new(update);
            let mut slice = vec![0; uint8array.length() as usize];
            uint8array.copy_to(&mut slice[..]);
            rmp_serde::from_slice(&slice).into_jserror()
        } else {
            update.into_serde().into_jserror()
        }
    }
/// Decode a `JsValue` into a `ViewerConfigUpdate` by auto-detecting format
/// from JavaScript type.
Decode a `JsValue` into a `ViewerConfigUpdate` by auto-detecting format
from JavaScript type.
Decode a ` JsValue ` into a ` ViewerConfigUpdate ` by auto - detecting format from JavaScript type .
pub fn decode(update: &JsValue) -> Result<Self, JsValue> {
        if update.is_string() {
            let js_str = update.as_string().into_jserror()?;
            let bytes = base64::decode(js_str).into_jserror()?;
            let mut decoder = ZlibDecoder::new(&*bytes);
            let mut decoded = vec![];
            decoder.read_to_end(&mut decoded).into_jserror()?;
            rmp_serde::from_slice(&decoded).into_jserror()
        } else if update.is_instance_of::<js_sys::ArrayBuffer>() {
            let uint8array = js_sys::Uint8Array::new(update);
            let mut slice = vec![0; uint8array.length() as usize];
            uint8array.copy_to(&mut slice[..]);
            rmp_serde::from_slice(&slice).into_jserror()
        } else {
            update.into_serde().into_jserror()
        }
    }
pub fn decode ( update : & JsValue ) -> Result < Self , JsValue > { if update . is_string ( ) { let js_str = update . as_string ( ) . into_jserror ( ) ? ; let bytes = base64 :: decode ( js_str ) . into_jserror ( ) ? ; let mut decoder = ZlibDecoder :: new ( & * bytes ) ; let mut decoded = vec ! [ ] ; decoder . read_to_end ( & mut decoded ) . into_jserror ( ) ? ; rmp_serde :: from_slice ( & decoded ) . into_jserror ( ) } else if update . is_instance_of :: < js_sys :: ArrayBuffer > ( ) { let uint8array = js_sys :: Uint8Array :: new ( update ) ; let mut slice = vec ! [ 0 uint8array length ( ) as usize ] ; uint8array . copy_to ( & mut slice [ .. ] ) ; rmp_serde :: from_slice ( & slice ) . into_jserror ( ) } else { update . into_serde ( ) . into_jserror ( ) } }
Decode a `JsValue` into a `ViewerConfigUpdate` by auto-detecting format
from JavaScript type.
Decode a ` JsValue ` into a ` ViewerConfigUpdate ` by auto - detecting format from JavaScript type .
update
&JsValue
update
&JsValue