pub fn accessor_data<'a>(&'a self, id: u64) -> Result<AccessorData<'a>, String> {
        let json = &self.json;
        
        let accessor_obj = 
            json.get("accessors")
                .and_then(|v| v.as_array())
                .and_then(|v| v.get(id as usize) as Option<&Value> )
                .and_then(|v| v.as_object())
                .ok_or(format!("Failed to read accessor with id {}", id))?;

        let component_count = accessor_obj.get("count")
            .and_then(|v| v.as_u64())
            .ok_or(format!("Failed to read count for accessor {}", id))? as u32;

        let component_ty = accessor_obj.get("componentType")
            .and_then(|v| v.as_u64())
            .map(|v| ComponentType::from_u64(v) )
            .ok_or(format!("Failed to read count for accessor {}", id))??;

        let ty = accessor_obj.get("type")
            .and_then(|v| v.as_str())
            .map(|v| AccessorType::from_str(v) )
            .ok_or(format!("Failed to read type for accessor {}", id))??;

        let data = {
            let buffer_view_id = accessor_obj.get("bufferView")
                .and_then(|v| v.as_u64())
                .ok_or(format!("Failed to read buffer view for accessor {}", id))?;

            let accessor_byte_offset = accessor_obj.get("byteOffset")
                .and_then(|v| v.as_u64())
                .unwrap_or(0);

            let buffer_view_obj = 
                json.get("bufferViews")
                    .and_then(|v| v.as_array())
                    .and_then(|v| v.get(buffer_view_id as usize) as Option<&Value> )
                    .and_then(|v| v.as_object())
                    .ok_or(format!("Failed to read buffer view with id {} from accessor id {}", buffer_view_id, id))?;
            
            let byte_length = buffer_view_obj.get("byteLength")
                .and_then(|v| v.as_u64())
                .ok_or(format!("Failed to read buffer view byte length for accessor {}", id))? as usize;

            let view_byte_offset = buffer_view_obj.get("byteOffset")
                .and_then(|v| v.as_u64())
                .unwrap_or(0);

            let combined_offset = (accessor_byte_offset + view_byte_offset) as isize;
            if combined_offset as usize > self.bin_chunk_size {
                return Err("Malformated json: mesh data points outside of the binary chunk".to_owned());
            }

            let file_offset = (combined_offset+self.bin_chunk_offset) as usize;
            &self.bin[file_offset..file_offset+byte_length]
        };

        let data = AccessorData {
            component_count,
            component_ty,
            ty,

            data
        };

        Ok(data)
    }
/// Return the data associated with the accessor identified by `id`
Return the data associated with the accessor identified by `id`
Return the data associated with the accessor identified by ` id `
pub fn accessor_data<'a>(&'a self, id: u64) -> Result<AccessorData<'a>, String> {
        let json = &self.json;
        let accessor_obj = 
            json.get("accessors")
                .and_then(|v| v.as_array())
                .and_then(|v| v.get(id as usize) as Option<&Value> )
                .and_then(|v| v.as_object())
                .ok_or(format!("Failed to read accessor with id {}", id))?;
        let component_count = accessor_obj.get("count")
            .and_then(|v| v.as_u64())
            .ok_or(format!("Failed to read count for accessor {}", id))? as u32;
        let component_ty = accessor_obj.get("componentType")
            .and_then(|v| v.as_u64())
            .map(|v| ComponentType::from_u64(v) )
            .ok_or(format!("Failed to read count for accessor {}", id))??;
        let ty = accessor_obj.get("type")
            .and_then(|v| v.as_str())
            .map(|v| AccessorType::from_str(v) )
            .ok_or(format!("Failed to read type for accessor {}", id))??;
        let data = {
            let buffer_view_id = accessor_obj.get("bufferView")
                .and_then(|v| v.as_u64())
                .ok_or(format!("Failed to read buffer view for accessor {}", id))?;
            let accessor_byte_offset = accessor_obj.get("byteOffset")
                .and_then(|v| v.as_u64())
                .unwrap_or(0);
            let buffer_view_obj = 
                json.get("bufferViews")
                    .and_then(|v| v.as_array())
                    .and_then(|v| v.get(buffer_view_id as usize) as Option<&Value> )
                    .and_then(|v| v.as_object())
                    .ok_or(format!("Failed to read buffer view with id {} from accessor id {}", buffer_view_id, id))?;
            let byte_length = buffer_view_obj.get("byteLength")
                .and_then(|v| v.as_u64())
                .ok_or(format!("Failed to read buffer view byte length for accessor {}", id))? as usize;
            let view_byte_offset = buffer_view_obj.get("byteOffset")
                .and_then(|v| v.as_u64())
                .unwrap_or(0);
            let combined_offset = (accessor_byte_offset + view_byte_offset) as isize;
            if combined_offset as usize > self.bin_chunk_size {
                return Err("Malformated json: mesh data points outside of the binary chunk".to_owned());
            }
            let file_offset = (combined_offset+self.bin_chunk_offset) as usize;
            &self.bin[file_offset..file_offset+byte_length]
        };
        let data = AccessorData {
            component_count,
            component_ty,
            ty,
            data
        };
        Ok(data)
    }
pub fn accessor_data < ' a > ( & ' a self , id : u64 ) -> Result < AccessorData < ' a > , String > { let json = & self . json ; let accessor_obj = json . get ( " " ) . and_then ( | v | v . as_array ( ) ) . and_then ( | v | v . get ( id as usize ) as Option < & Value > ) . and_then ( | v | v . as_object ( ) ) . ok_or ( format ! ( " " id ) ) ? ; let component_count = accessor_obj . get ( " " ) . and_then ( | v | v . as_u64 ( ) ) . ok_or ( format ! ( " " id ) ) ? as u32 ; let component_ty = accessor_obj . get ( " " ) . and_then ( | v | v . as_u64 ( ) ) . map ( | v | ComponentType :: from_u64 ( v ) ) . ok_or ( format ! ( " " id ) ) ? ? ; let ty = accessor_obj . get ( " " ) . and_then ( | v | v . as_str ( ) ) . map ( | v | AccessorType :: from_str ( v ) ) . ok_or ( format ! ( " " id ) ) ? ? ; let data = { let buffer_view_id = accessor_obj . get ( " " ) . and_then ( | v | v . as_u64 ( ) ) . ok_or ( format ! ( " " id ) ) ? ; let accessor_byte_offset = accessor_obj . get ( " " ) . and_then ( | v | v . as_u64 ( ) ) . unwrap_or ( 0 ) ; let buffer_view_obj = json . get ( " " ) . and_then ( | v | v . as_array ( ) ) . and_then ( | v | v . get ( buffer_view_id as usize ) as Option < & Value > ) . and_then ( | v | v . as_object ( ) ) . ok_or ( format ! ( " " buffer_view_id id ) ) ? ; let byte_length = buffer_view_obj . get ( " " ) . and_then ( | v | v . as_u64 ( ) ) . ok_or ( format ! ( " " id ) ) ? as usize ; let view_byte_offset = buffer_view_obj . get ( " " ) . and_then ( | v | v . as_u64 ( ) ) . unwrap_or ( 0 ) ; let combined_offset = ( accessor_byte_offset + view_byte_offset ) as isize ; if combined_offset as usize > self . bin_chunk_size { return Err ( " " . to_owned ( ) ) ; } let file_offset = ( combined_offset + self . bin_chunk_offset ) as usize ; & self . bin [ file_offset .. file_offset + byte_length ] } ; let data = AccessorData { component_count , component_ty , ty , data } ; Ok ( data ) }
Return the data associated with the accessor identified by `id`
Return the data associated with the accessor identified by ` id `
&'a self
id
u64