pub fn deserialize_binary<R: Read>(
    reader: R,
    bytes_limit: Option<u64>,
) -> std::result::Result<BpfThreadMap, DeserializationError> {
    let result = match bytes_limit {
        // Also add the default options. These are not part of the `DefaultOptions` as per
        // this issue: https://github.com/servo/bincode/issues/333
        Some(limit) => DefaultOptions::new()
            .with_fixint_encoding()
            .allow_trailing_bytes()
            .with_limit(limit)
            .deserialize_from::<R, HashMap<String, BpfProgram>>(reader),
        // No limit is the default.
        None => bincode::deserialize_from::<R, HashMap<String, BpfProgram>>(reader),
    };

    Ok(result
        .map_err(DeserializationError::Bincode)?
        .into_iter()
        .map(|(k, v)| (k.to_lowercase(), Arc::new(v)))
        .collect())
}
/// Deserialize a BPF file into a collection of usable BPF filters.
/// Has an optional `bytes_limit` that is passed to bincode to constrain the maximum amount of memory
/// that we can allocate while performing the deserialization.
/// It's recommended that the integrator of the library uses this to prevent memory allocations DOS-es.
Deserialize a BPF file into a collection of usable BPF filters.
Has an optional `bytes_limit` that is passed to bincode to constrain the maximum amount of memory
that we can allocate while performing the deserialization.
It's recommended that the integrator of the library uses this to prevent memory allocations DOS-es.
Deserialize a BPF file into a collection of usable BPF filters . Has an optional ` bytes_limit ` that is passed to bincode to constrain the maximum amount of memory that we can allocate while performing the deserialization . It ' s recommended that the integrator of the library uses this to prevent memory allocations DOS - es .
pub fn deserialize_binary<R: Read>(
    reader: R,
    bytes_limit: Option<u64>,
) -> std::result::Result<BpfThreadMap, DeserializationError> {
    let result = match bytes_limit {
        // Also add the default options. These are not part of the `DefaultOptions` as per
        // this issue: https://github.com/servo/bincode/issues/333
        Some(limit) => DefaultOptions::new()
            .with_fixint_encoding()
            .allow_trailing_bytes()
            .with_limit(limit)
            .deserialize_from::<R, HashMap<String, BpfProgram>>(reader),
        // No limit is the default.
        None => bincode::deserialize_from::<R, HashMap<String, BpfProgram>>(reader),
    };
    Ok(result
        .map_err(DeserializationError::Bincode)?
        .into_iter()
        .map(|(k, v)| (k.to_lowercase(), Arc::new(v)))
        .collect())
}
pub fn deserialize_binary < R : Read > ( reader : R , bytes_limit : Option < u64 > , ) -> std :: result :: Result < BpfThreadMap , DeserializationError > { let result = match bytes_limit { // Also add the default options. These are not part of the `DefaultOptions` as per // this issue: https://github.com/servo/bincode/issues/333 Some ( limit ) => DefaultOptions :: new ( ) . with_fixint_encoding ( ) . allow_trailing_bytes ( ) . with_limit ( limit ) . deserialize_from :: < R , HashMap < String , BpfProgram > > ( reader ) , // No limit is the default. None => bincode :: deserialize_from :: < R , HashMap < String , BpfProgram > > ( reader ) , } ; Ok ( result . map_err ( DeserializationError :: Bincode ) ? . into_iter ( ) . map ( | ( k , v ) | ( k . to_lowercase ( ) , Arc :: new ( v ) ) ) . collect ( ) ) }
Deserialize a BPF file into a collection of usable BPF filters.
Deserialize a BPF file into a collection of usable BPF filters .
reader
R
bytes_limit
Option<u64>
reader
R
bytes_limit
Option<u64>