difftreelog
Merge pull request #138 from CertainLach/stable-async-traits
in: master
7 files changed
.github/workflows/clippy_check.ymldiffbeforeafterboth7 - uses: actions/checkout@v27 - uses: actions/checkout@v28 - uses: actions-rs/toolchain@v18 - uses: actions-rs/toolchain@v19 with:9 with:10 toolchain: nightly10 toolchain: nightly-2023-10-2811 components: clippy11 components: clippy12 override: true12 override: true13 - uses: actions-rs/clippy-check@v113 - uses: actions-rs/clippy-check@v1Cargo.lockdiffbeforeafterboth111 "smallvec",111 "smallvec",112]112]113114[[package]]115name = "async-trait"116version = "0.1.74"117source = "registry+https://github.com/rust-lang/crates.io-index"118checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9"119dependencies = [120 "proc-macro2",121 "quote",122 "syn 2.0.38",123]124113125[[package]]114[[package]]126name = "autocfg"115name = "autocfg"598dependencies = [587dependencies = [599 "annotate-snippets",588 "annotate-snippets",600 "anyhow",589 "anyhow",601 "async-trait",602 "bincode",590 "bincode",603 "derivative",591 "derivative",604 "hashbrown 0.14.2",592 "hashbrown 0.14.2",801789802[[package]]790[[package]]803name = "logos"791name = "logos"804version = "0.13.0"792version = "0.12.1"805source = "registry+https://github.com/rust-lang/crates.io-index"793source = "registry+https://github.com/rust-lang/crates.io-index"806checksum = "c000ca4d908ff18ac99b93a062cb8958d331c3220719c52e77cb19cc6ac5d2c1"794checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1"807dependencies = [795dependencies = [808 "logos-derive",796 "logos-derive",809]797]810798811[[package]]799[[package]]812name = "logos-codegen"800name = "logos-derive"813version = "0.13.0"801version = "0.12.1"814source = "registry+https://github.com/rust-lang/crates.io-index"802source = "registry+https://github.com/rust-lang/crates.io-index"815checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68"803checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"816dependencies = [804dependencies = [817 "beef",805 "beef",818 "fnv",806 "fnv",819 "proc-macro2",807 "proc-macro2",820 "quote",808 "quote",821 "regex-syntax",809 "regex-syntax",822 "syn 2.0.38",810 "syn 1.0.109",823]811]824825[[package]]826name = "logos-derive"827version = "0.13.0"828source = "registry+https://github.com/rust-lang/crates.io-index"829checksum = "dbfc0d229f1f42d790440136d941afd806bc9e949e2bcb8faa813b0f00d1267e"830dependencies = [831 "logos-codegen",832]833812834[[package]]813[[package]]835name = "lsp-server"814name = "lsp-server"Cargo.tomldiffbeforeafterboth35rustc-hash = "1.1"35rustc-hash = "1.1"36bincode = "1.3"36bincode = "1.3"37annotate-snippets = "0.9.1"37annotate-snippets = "0.9.1"38async-trait = "0.1.60"39num-bigint = "0.4.3"38num-bigint = "0.4.3"40derivative = "2.2.0"39derivative = "2.2.0"41strsim = "0.10.0"40strsim = "0.10.0"45syn = "2.0"44syn = "2.0"46peg = "0.8.2"45peg = "0.8.2"47drop_bomb = "0.1.5"46drop_bomb = "0.1.5"48logos = "0.13.0"47logos = "0.12.0"49miette = "5.5.0"48miette = "5.5.0"50rowan = "0.15"49rowan = "0.15"51text-size = "1.1"50text-size = "1.1"crates/jrsonnet-evaluator/Cargo.tomldiffbeforeafterboth14# Allows library authors to throw custom errors14# Allows library authors to throw custom errors15anyhow-error = ["anyhow"]15anyhow-error = ["anyhow"]16# Adds ability to build import closure in async16# Adds ability to build import closure in async17async-import = ["async-trait"]17async-import = []181819# Allows to preserve field order in objects19# Allows to preserve field order in objects20exp-preserve-order = []20exp-preserve-order = []54bincode = { workspace = true, optional = true }54bincode = { workspace = true, optional = true }55# Explaining traces55# Explaining traces56annotate-snippets = { workspace = true, features = ["color"], optional = true }56annotate-snippets = { workspace = true, features = ["color"], optional = true }57# Async imports58async-trait = { workspace = true, optional = true }59# Bigint57# Bigint60num-bigint = { workspace = true, features = ["serde"], optional = true }58num-bigint = { workspace = true, features = ["serde"], optional = true }61derivative.workspace = true59derivative.workspace = truecrates/jrsonnet-evaluator/src/async_import.rsdiffbeforeafterboth1use std::{cell::RefCell, path::Path};1use std::{cell::RefCell, future::Future, path::Path};223use async_trait::async_trait;4use jrsonnet_gcmodule::Trace;3use jrsonnet_gcmodule::Trace;5use jrsonnet_interner::IStr;4use jrsonnet_interner::IStr;6use jrsonnet_parser::{5use jrsonnet_parser::{218 }217 }219}218}220219221#[async_trait(?Send)]222pub trait AsyncImportResolver {220pub trait AsyncImportResolver {223 type Error;221 type Error;224 /// Resolves file path, e.g. `(/home/user/manifests, b.libjsonnet)` can correspond222 /// Resolves file path, e.g. `(/home/user/manifests, b.libjsonnet)` can correspond225 /// both to `/home/user/manifests/b.libjsonnet` and to `/home/user/${vendor}/b.libjsonnet`223 /// both to `/home/user/manifests/b.libjsonnet` and to `/home/user/${vendor}/b.libjsonnet`226 /// where `${vendor}` is a library path.224 /// where `${vendor}` is a library path.227 ///225 ///228 /// `from` should only be returned from [`ImportResolver::resolve`], or from other defined file, any other value226 /// `from` should only be returned from [`ImportResolver::resolve`],229 /// may result in panic227 /// or from other defined file, any other value may result in panic230 async fn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath, Self::Error>;228 fn resolve_from(229 &self,230 from: &SourcePath,231 path: &str,232 ) -> impl Future<Output = Result<SourcePath, Self::Error>>;231 async fn resolve_from_default(&self, path: &str) -> Result<SourcePath, Self::Error> {233 fn resolve_from_default(234 &self,235 path: &str,236 ) -> impl Future<Output = Result<SourcePath, Self::Error>> {232 self.resolve_from(&SourcePath::default(), path).await237 async { self.resolve_from(&SourcePath::default(), path).await }233 }238 }234 /// Resolves absolute path, doesn't supports jpath and other fancy things239 /// Resolves absolute path, doesn't supports jpath and other fancy things235 async fn resolve(&self, path: &Path) -> Result<SourcePath, Self::Error>;240 fn resolve(&self, path: &Path) -> impl Future<Output = Result<SourcePath, Self::Error>>;236241237 /// Load resolved file242 /// Load resolved file243 /// This should only be called with value returned238 /// This should only be called with value returned from [`ImportResolver::resolve_file`]/[`ImportResolver::resolve`],244 /// from [`ImportResolver::resolve_file`]/[`ImportResolver::resolve`],245 /// this cannot be resolved using associated type,239 /// this cannot be resolved using associated type, as evaluator uses object instead of generic for [`ImportResolver`]246 /// as the evaluator uses object instead of generic for [`ImportResolver`]240 async fn load_file_contents(&self, resolved: &SourcePath) -> Result<Vec<u8>, Self::Error>;247 fn load_file_contents(248 &self,249 resolved: &SourcePath,250 ) -> impl Future<Output = Result<Vec<u8>, Self::Error>>;241}251}242252243#[derive(Trace)]253#[derive(Trace)]flake.nixdiffbeforeafterboth25 lib = pkgs.lib;25 lib = pkgs.lib;26 rust =26 rust =27 (pkgs.rustChannelOf {27 (pkgs.rustChannelOf {28 date = "2023-08-02";28 date = "2023-10-28";29 channel = "nightly";29 channel = "nightly";30 })30 })31 .default31 .defaultrust-toolchain.tomldiffbeforeafterbothno changes