diff options
author | Florian Klink <flokli@flokli.de> | 2024-11-12T11·32+0100 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2024-11-12T14·05+0000 |
commit | b1764e11092f7817633ae013508e6285585ac1cf (patch) | |
tree | 85a5091fa75c9a24f49404e968fbeb9a8b3a3f44 /tvix | |
parent | 0b8ec03797bc8ace0e1db979ae87a00be2c98733 (diff) |
refactor(nix-compat/nix_daemon): drop Sync requirement for StorePath r/8915
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<S> impl. Co-Authored-By: edef@edef.eu Change-Id: I8427b38d2bd61de2818088728cbad79cda69d17d Reviewed-on: https://cl.tvl.fyi/c/depot/+/12764 Reviewed-by: Vladimir Kryachko <v.kryachko@gmail.com> Autosubmit: flokli <flokli@flokli.de> Reviewed-by: edef <edef@edef.eu> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/nix-compat/src/nix_daemon/types.rs | 11 |
1 files 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<String> { // Custom implementation since Display does not use absolute paths. impl<S> NixSerialize for StorePath<S> where - S: AsRef<str> + Sync, + S: AsRef<str>, { - async fn serialize<W>(&self, writer: &mut W) -> Result<(), W::Error> + fn serialize<W>(&self, writer: &mut W) -> impl Future<Output = Result<(), W::Error>> + 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 } } } |