pub fn copy_measured<R: SgxsRead, W: SgxsWrite>(reader: &mut R, writer: &mut W) -> Result<()> {
    while let Some(meas) = reader.read_meas()? {
        match meas {
            Meas::Unsized(_) => return Err(Error::StreamUnsized.into()),
            Meas::Unmeasured { .. } => (),
            meas => writer.write_meas(&meas)?,
        }
    }

    Ok(())
}
/// Copy only the measured bits of an SGXS stream.
///
/// # Example
/// Compute ENCLAVEHASH from an SGXS:
///
/// ```
/// extern crate crypto_hash;
/// extern crate sgxs;
/// use crypto_hash::{Hasher, Algorithm};
/// use sgxs::sgxs::{SgxsRead, Result, copy_measured};
///
/// fn enclavehash<R: SgxsRead>(stream: &mut R) -> Result<[u8; 32]> {
///     let mut hasher = Hasher::new(Algorithm::SHA256);
///     copy_measured(stream, &mut hasher)?;
///     let mut hash = [0u8; 32];
///     hash.copy_from_slice(&hasher.finish());
///     Ok(hash)
/// }
///
/// # fn main() { /* compile test */ }
/// ```
Copy only the measured bits of an SGXS stream.
Copy only the measured bits of an SGXS stream .
pub fn copy_measured<R: SgxsRead, W: SgxsWrite>(reader: &mut R, writer: &mut W) -> Result<()> {
    while let Some(meas) = reader.read_meas()? {
        match meas {
            Meas::Unsized(_) => return Err(Error::StreamUnsized.into()),
            Meas::Unmeasured { .. } => (),
            meas => writer.write_meas(&meas)?,
        }
    }
    Ok(())
}
pub fn copy_measured < R : SgxsRead , W : SgxsWrite > ( reader : & mut R , writer : & mut W ) -> Result < ( ) > { while let Some ( meas ) = reader . read_meas ( ) ? { match meas { Meas :: Unsized ( _ ) => return Err ( Error :: StreamUnsized . into ( ) ) , Meas :: Unmeasured { .. } => ( ) , meas => writer . write_meas ( & meas ) ? , } } Ok ( ( ) ) }
Copy only the measured bits of an SGXS stream.
Copy only the measured bits of an SGXS stream .
reader
&mut R
writer
&mut W
reader
&mut R
writer
&mut W
example
Compute ENCLAVEHASH from an SGXS.

```
extern crate crypto_hash;
extern crate sgxs;
use crypto_hash::{Hasher, Algorithm};
use sgxs::sgxs::{SgxsRead, Result, copy_measured}.

fn enclavehash(stream: &mut R) -> Result<[u8; 32]> {
let mut hasher = Hasher::new(Algorithm::SHA256);
copy_measured(stream, &mut hasher)?;
let mut hash = [0u8; 32];
hash.copy_from_slice(&hasher.finish());
Ok(hash)
}
Compute ENCLAVEHASH from an SGXS . ` ` ` extern crate crypto_hash ; extern crate sgxs ; use crypto_hash :: { Hasher Algorithm } ; use sgxs :: sgxs :: { SgxsRead Result copy_measured } . fn enclavehash ( stream : &mut R ) - > Result< [ u8 ; 32 ] > { let mut hasher = Hasher :: new ( Algorithm :: SHA256 ) ; copy_measured ( stream &mut hasher ) ? ; let mut hash = [ 0u8 ; 32 ] ; hash . copy_from_slice ( &hasher . finish () ) ; Ok ( hash ) }
fn main() { /* compile test */ }
None