ntdsextract2 1.4.23

Display contents of Active Directory database files (ntds.dit)
use dfir_windows_types::Sid;

use crate::cache::Value;

use crate::ntds::Error;

use super::FromValue;

impl FromValue for Sid {
    fn from_value_opt(value: &Value) -> Result<Option<Self>, Error>
    where
        Self: Sized,
    {
        match value {
            Value::Binary(val) | Value::LargeBinary(val) => Ok(Some(Sid::try_from(&val[..])?)),
            Value::Null(()) => Ok(None),
            _ => Err(Error::InvalidValueDetected(
                value.to_string(),
                "Sid (binary)",
            )),
        }
    }
}