1 | use crate::io::{Error, ErrorKind, Result}; |
---|---|
2 | use core::mem::size_of; |
3 | pub const ERROR_ZST_FORBIDDEN: &str = "Collections of zero-sized types are not allowed due to deny-of-service concerns on deserialization."; |
4 | |
5 | pub(crate) fn check_zst<T>() -> Result<()> { |
6 | if size_of::<T>() == 0 { |
7 | return Err(Error::new(kind:ErrorKind::InvalidData, ERROR_ZST_FORBIDDEN)); |
8 | } |
9 | Ok(()) |
10 | } |
11 |