Repository: qdrant/qdrant
File: lib/collection/src/operations/loggable.rs (Rust)

Code before:
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.0.hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for Arc<FacetParams> {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self.as_ref()).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "facet"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.as_ref().hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for Arc<CountRequestInternal> {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self.as_ref()).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "count"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.as_ref().hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for Arc<PointRequestInternal> {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self.as_ref()).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "retrieve"

Review comment (suggestion):
I vote to implement on `FacetParams` instead, as it allows wider usage.

We could do it together with an auto trait on `Arc<Loggable>` like this:


```suggestion

impl<L> Loggable for Arc<L>
where
    for<'a> &'a L: Loggable,
{
    #[inline]
    fn to_log_value(&self) -> Value {
        self.as_ref().to_log_value()
    }

    #[inline]
    fn request_name(&self) -> &'static str {
        self.as_ref().request_name()
    }

    #[inline]
    fn request_hash(&self) -> u64 {
        self.as_ref().request_hash()
    }
}

impl Loggable for &FacetParams {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "facet"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}
```

Code after:
    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}

impl<T: Loggable> Loggable for Arc<T> {
    fn to_log_value(&self) -> Value {
        self.as_ref().to_log_value()
    }

    fn request_name(&self) -> &'static str {
        self.as_ref().request_name()
    }

    fn request_hash(&self) -> u64 {
        self.as_ref().request_hash()
    }
}

impl Loggable for FacetParams {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "facet"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);
        self.hash(&mut hasher);
        hasher.finish()
    }
}

impl Loggable for CountRequestInternal {
    fn to_log_value(&self) -> Value {
        serde_json::to_value(self).unwrap_or_default()
    }

    fn request_name(&self) -> &'static str {
        "count"
    }

    fn request_hash(&self) -> u64 {
        let mut hasher = DefaultHasher::new();
        self.request_name().hash(&mut hasher);