From b1764e11092f7817633ae013508e6285585ac1cf Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Tue, 12 Nov 2024 12:32:26 +0100 Subject: refactor(nix-compat/nix_daemon): drop Sync requirement for StorePath By manually writing out the async function, and moving the owned String we can avoid for S to be Sync in the NixSerialize for StorePath impl. Co-Authored-By: edef@edef.eu Change-Id: I8427b38d2bd61de2818088728cbad79cda69d17d Reviewed-on: https://cl.tvl.fyi/c/depot/+/12764 Reviewed-by: Vladimir Kryachko Autosubmit: flokli Reviewed-by: edef Tested-by: BuildkiteCI --- tvix/nix-compat/src/nix_daemon/types.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tvix/nix-compat/src/nix_daemon/types.rs b/tvix/nix-compat/src/nix_daemon/types.rs index 33b74f37574f..db7d26321e3e 100644 --- a/tvix/nix-compat/src/nix_daemon/types.rs +++ b/tvix/nix-compat/src/nix_daemon/types.rs @@ -1,5 +1,3 @@ -use nix_compat_derive::{NixDeserialize, NixSerialize}; - use crate::{ narinfo::Signature, nixhash::CAHash, @@ -9,6 +7,8 @@ use crate::{ ser::{NixSerialize, NixWrite}, }, }; +use nix_compat_derive::{NixDeserialize, NixSerialize}; +use std::future::Future; /// Marker type that consumes/sends and ignores a u64. #[derive(Clone, Debug, NixDeserialize, NixSerialize)] @@ -128,13 +128,14 @@ impl NixDeserialize for StorePath { // Custom implementation since Display does not use absolute paths. impl NixSerialize for StorePath where - S: AsRef + Sync, + S: AsRef, { - async fn serialize(&self, writer: &mut W) -> Result<(), W::Error> + fn serialize(&self, writer: &mut W) -> impl Future> + Send where W: NixWrite, { - writer.write_value(&self.to_absolute_path()).await + let sp = self.to_absolute_path(); + async move { writer.write_value(&sp).await } } } -- cgit 1.4.1