bcc 0.0.34

Idiomatic Rust bindings for BPF Compiler Collection (BCC)
Documentation
1
2
3
4
5
6
7
8
use std::ffi::CString;

use crate::error::BccError;

/// Converts a string to a `CString`, with a user-friendly error message if invalid.
pub fn to_cstring<S: Into<String>>(value: S, field: &'static str) -> Result<CString, BccError> {
    CString::new(value.into()).map_err(|_| BccError::InvalidCString { field })
}