aboutsummaryrefslogtreecommitdiff
path: root/src/expr/immediate.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/expr/immediate.rs')
-rw-r--r--src/expr/immediate.rs24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/expr/immediate.rs b/src/expr/immediate.rs
index 0787e06..71453b3 100644
--- a/src/expr/immediate.rs
+++ b/src/expr/immediate.rs
@@ -3,8 +3,8 @@ use crate::sys;
use std::ffi::c_void;
use std::os::raw::c_char;
-/// An immediate expression. Used to set immediate data.
-/// Verdicts are handled separately by [crate::expr::Verdict].
+/// An immediate expression. Used to set immediate data. Verdicts are handled separately by
+/// [crate::expr::Verdict].
#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct Immediate<T> {
pub data: T,
@@ -50,11 +50,10 @@ impl<const N: usize> Expression for Immediate<[u8; N]> {
Immediate::<u8>::get_raw_name()
}
- /// The raw data contained inside `Immediate` expressions can only be deserialized to
- /// arrays of bytes, to ensure that the memory layout of retrieved data cannot be
- /// violated. It is your responsibility to provide the correct length of the byte
- /// data. If the data size is invalid, you will get the error
- /// `DeserializationError::InvalidDataSize`.
+ /// The raw data contained inside `Immediate` expressions can only be deserialized to arrays of
+ /// bytes, to ensure that the memory layout of retrieved data cannot be violated. It is your
+ /// responsibility to provide the correct length of the byte data. If the data size is invalid,
+ /// you will get the error `DeserializationError::InvalidDataSize`.
///
/// Example (warning, no error checking!):
/// ```rust
@@ -72,12 +71,11 @@ impl<const N: usize> Expression for Immediate<[u8; N]> {
/// println!("{:?}", expr.decode_expr::<Immediate<[u8; 1]>>().unwrap());
/// }
/// ```
- /// These limitations occur because casting bytes to any type of the same size
- /// as the raw input would be *extremely* dangerous in terms of memory safety.
- // As casting bytes to any type of the same size as the input would
- // be *extremely* dangerous in terms of memory safety,
- // rustables only accept to deserialize expressions with variable-size data
- // to arrays of bytes, so that the memory layout cannot be invalid.
+ /// These limitations occur because casting bytes to any type of the same size as the raw input
+ /// would be *extremely* dangerous in terms of memory safety.
+ // As casting bytes to any type of the same size as the input would be *extremely* dangerous in
+ // terms of memory safety, rustables only accept to deserialize expressions with variable-size
+ // data to arrays of bytes, so that the memory layout cannot be invalid.
fn from_expr(expr: *const sys::nftnl_expr) -> Result<Self, DeserializationError> {
unsafe {
let ref_len = std::mem::size_of::<[u8; N]>() as u32;