diff --git a/Cargo.lock b/Cargo.lock index 775f7f9..be65ec2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -101,8 +101,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cgp" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "808e618db803f54e4222fffa79a773285c00db6766977d3cacae793eca9b1577" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", "cgp-extra", @@ -111,8 +110,7 @@ dependencies = [ [[package]] name = "cgp-async-macro" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c854822d7b7700c223e648f2e2b3b8dea47e53aa858db7dc7a805adb211205" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "proc-macro2", "quote", @@ -122,14 +120,12 @@ dependencies = [ [[package]] name = "cgp-component" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "aabbf574096bd7a9a79cc0f24989f49060aaf7f86bce2756fb7cc3e096ad59f2" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" [[package]] name = "cgp-core" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f16d4a2a938b2b11d078f10b4893b8295027c616ec6134fa09e877580f9d95c8" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-async-macro", "cgp-component", @@ -142,8 +138,7 @@ dependencies = [ [[package]] name = "cgp-dispatch" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5be0990bad684ba4e40aa8fc73c8138ea28ca3f6068f336af8a82813250a6fa0" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", "cgp-handler", @@ -153,8 +148,7 @@ dependencies = [ [[package]] name = "cgp-error" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613b07f14aef847187014d72eb462f59667661cbe614ae249ce34c380f7ff2f9" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-component", "cgp-macro", @@ -164,8 +158,7 @@ dependencies = [ [[package]] name = "cgp-error-anyhow" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cb9fb8c72a75459069308e724c8a747193d7879c2c79d22effbfdef118cdd9b" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "anyhow", "cgp-core", @@ -174,8 +167,7 @@ dependencies = [ [[package]] name = "cgp-error-extra" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6eeff288cf174bb131fe3bc1e2d6038a68bf7fcc720e2e02589b6466c0112d94" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", ] @@ -183,8 +175,7 @@ dependencies = [ [[package]] name = "cgp-extra" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bc7f97cd02144bf566a8dca6a11a806efccb6637240ffe953c26462dd1bd0b0" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", "cgp-dispatch", @@ -200,8 +191,7 @@ dependencies = [ [[package]] name = "cgp-extra-macro" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cda176978a134ef8554fd7e256666e898f62e43b882c407cc2bff47c00f8b0d" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-extra-macro-lib", "syn", @@ -210,8 +200,7 @@ dependencies = [ [[package]] name = "cgp-extra-macro-lib" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "546ce09e1bf7ff8e874740fafcbe522cb900beb831e24676fd634c4836c1ecc5" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "proc-macro2", "quote", @@ -221,8 +210,7 @@ dependencies = [ [[package]] name = "cgp-field" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd42a320b4b4d020114fe25874c313e662b514354c7e0bf0e3298754216cb48f" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-component", "cgp-type", @@ -231,8 +219,7 @@ dependencies = [ [[package]] name = "cgp-field-extra" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6d86f16a5f5ba3ef0464d646b3fc6f085d97af0cb817c0dc6b3ca5d3bbe83f" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-field", ] @@ -240,8 +227,7 @@ dependencies = [ [[package]] name = "cgp-handler" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "17d7e0e09206a6abf88eefbe04d9017b2ab53e18a0b9a3039933b2a8ee8c660b" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", ] @@ -249,8 +235,7 @@ dependencies = [ [[package]] name = "cgp-macro" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e440bf54f108b91f177dae8801b5e810fb413709b6732d0ada37ba47aebf407" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-macro-lib", "syn", @@ -259,8 +244,7 @@ dependencies = [ [[package]] name = "cgp-macro-lib" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86884fa366cc3d2f0bef610c9a6ce2b48451ed101eac0c300104029af96f1e7" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "itertools", "prettyplease", @@ -272,8 +256,7 @@ dependencies = [ [[package]] name = "cgp-monad" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "448e04f87f64ba6677de22559a422f04b4f2cb29fb62b16dbe5ed7677d873fb3" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", "cgp-handler", @@ -282,8 +265,7 @@ dependencies = [ [[package]] name = "cgp-run" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c8c0e58e0e4f373405143799892ee37101174a83fe9e00ad8d2d22cd4cbedd9" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", ] @@ -291,8 +273,7 @@ dependencies = [ [[package]] name = "cgp-runtime" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f98e8d13664dcd0d809b945b982a934001adcf2e99875b88a1a4985f450375c" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-core", ] @@ -300,8 +281,7 @@ dependencies = [ [[package]] name = "cgp-type" version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "301243ad41daca746950f71ab9ae257836bbbb0a7004990a601a9726ade5be23" +source = "git+https://github.com/contextgeneric/cgp.git#3b8befaffb2d2624cba32f2a62359040c59a8ba1" dependencies = [ "cgp-component", "cgp-macro", diff --git a/Cargo.toml b/Cargo.toml index bbd6d3a..5a31535 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,5 +58,5 @@ hypershell-tungstenite-components = { path = "./crates/hypershell-tungstenite- hypershell-hash-components = { path = "./crates/hypershell-hash-components" } hypershell-macro = { path = "./crates/hypershell-macro" } -# cgp = { git = "https://github.com/contextgeneric/cgp.git", branch = "v0.5.0-release" } -# cgp-error-anyhow = { git = "https://github.com/contextgeneric/cgp.git", branch = "v0.5.0-release" } +cgp = { git = "https://github.com/contextgeneric/cgp.git" } +cgp-error-anyhow = { git = "https://github.com/contextgeneric/cgp.git" } diff --git a/crates/hypershell-components/src/providers/box_async.rs b/crates/hypershell-components/src/providers/box_async.rs index f2967c3..4586290 100644 --- a/crates/hypershell-components/src/providers/box_async.rs +++ b/crates/hypershell-components/src/providers/box_async.rs @@ -5,8 +5,8 @@ use core::pin::Pin; use cgp::extra::handler::{Handler, HandlerComponent}; use cgp::prelude::*; -#[cgp_new_provider] -impl Handler for BoxHandler +#[cgp_impl(new BoxHandler)] +impl Handler for Context where Context: HasErrorType, InHandler: 'static + Handler, diff --git a/crates/hypershell-components/src/providers/call.rs b/crates/hypershell-components/src/providers/call.rs index ba3964f..d28a287 100644 --- a/crates/hypershell-components/src/providers/call.rs +++ b/crates/hypershell-components/src/providers/call.rs @@ -3,8 +3,8 @@ use core::marker::PhantomData; use cgp::extra::handler::{CanHandle, Handler, HandlerComponent}; use cgp::prelude::*; -#[cgp_new_provider] -impl Handler for Call +#[cgp_impl(new Call)] +impl Handler for Context where Context: CanHandle, { diff --git a/crates/hypershell-components/src/providers/convert.rs b/crates/hypershell-components/src/providers/convert.rs index add4200..3aef3d9 100644 --- a/crates/hypershell-components/src/providers/convert.rs +++ b/crates/hypershell-components/src/providers/convert.rs @@ -9,8 +9,8 @@ use cgp::prelude::*; use crate::dsl::ConvertTo; -#[cgp_new_provider] -impl Computer, Input> for HandleConvert +#[cgp_impl(new HandleConvert)] +impl Computer, Input> for Context where Input: Into, { @@ -21,8 +21,8 @@ where } } -#[cgp_new_provider] -impl Handler for DecodeUtf8Bytes +#[cgp_impl(new DecodeUtf8Bytes)] +impl Handler for Context where Context: CanRaiseError + for<'a> CanWrapError>, Input: AsRef<[u8]>, diff --git a/crates/hypershell-components/src/providers/method_arg.rs b/crates/hypershell-components/src/providers/method_arg.rs index 45e0c44..bf9c87e 100644 --- a/crates/hypershell-components/src/providers/method_arg.rs +++ b/crates/hypershell-components/src/providers/method_arg.rs @@ -5,8 +5,8 @@ use cgp::prelude::*; use crate::components::{HasHttpMethodType, MethodArgExtractor, MethodArgExtractorComponent}; use crate::dsl::FieldArg; -#[cgp_new_provider] -impl MethodArgExtractor> for ExtractMethodFieldArg +#[cgp_impl(new ExtractMethodFieldArg)] +impl MethodArgExtractor> for Context where Context: HasHttpMethodType + HasField, Context::HttpMethod: Clone, diff --git a/crates/hypershell-components/src/providers/return.rs b/crates/hypershell-components/src/providers/return.rs index 07cdaf2..a384f8f 100644 --- a/crates/hypershell-components/src/providers/return.rs +++ b/crates/hypershell-components/src/providers/return.rs @@ -3,8 +3,8 @@ use core::marker::PhantomData; use cgp::extra::handler::{Handler, HandlerComponent}; use cgp::prelude::*; -#[cgp_new_provider] -impl Handler for ReturnInput +#[cgp_impl(new ReturnInput)] +impl Handler for Context where Context: HasErrorType, { diff --git a/crates/hypershell-components/src/providers/string_arg.rs b/crates/hypershell-components/src/providers/string_arg.rs index 654d544..c495008 100644 --- a/crates/hypershell-components/src/providers/string_arg.rs +++ b/crates/hypershell-components/src/providers/string_arg.rs @@ -12,8 +12,8 @@ use crate::components::{ }; use crate::dsl::{FieldArg, JoinArgs, StaticArg}; -#[cgp_new_provider] -impl CommandArgExtractor for ExtractStringCommandArg +#[cgp_impl(new ExtractStringCommandArg)] +impl CommandArgExtractor for Context where Context: HasCommandArgType + CanExtractStringArg, Context::CommandArg: From, @@ -23,8 +23,8 @@ where } } -#[cgp_new_provider] -impl StringArgExtractor> for ExtractStaticArg +#[cgp_impl(new ExtractStaticArg)] +impl StringArgExtractor> for Context where Arg: Default + Display, { @@ -36,8 +36,8 @@ where } } -#[cgp_new_provider] -impl StringArgExtractor> for ExtractFieldArg +#[cgp_impl(new ExtractFieldArg)] +impl StringArgExtractor> for Context where Context: HasField, { @@ -48,25 +48,25 @@ where pub struct JoinStringArgs; -#[cgp_provider] -impl StringArgExtractor>> for JoinStringArgs +#[cgp_impl(JoinStringArgs)] +impl StringArgExtractor>> for Context where Context: CanExtractStringArg, - Self: StringArgExtractor>, + JoinStringArgs: StringArgExtractor>, { fn extract_string_arg( context: &Context, _phantom: PhantomData>>, ) -> Cow<'_, str> { let arg = context.extract_string_arg(PhantomData); - let args = Self::extract_string_arg(context, PhantomData::>); + let args = JoinStringArgs::extract_string_arg(context, PhantomData::>); format!("{arg}{args}").into() } } -#[cgp_provider] -impl StringArgExtractor> for JoinStringArgs { +#[cgp_impl(JoinStringArgs)] +impl StringArgExtractor> for Context { fn extract_string_arg( _context: &Context, _phantom: PhantomData>, diff --git a/crates/hypershell-components/src/providers/url_arg.rs b/crates/hypershell-components/src/providers/url_arg.rs index a96e592..8728290 100644 --- a/crates/hypershell-components/src/providers/url_arg.rs +++ b/crates/hypershell-components/src/providers/url_arg.rs @@ -8,8 +8,8 @@ use crate::components::{ }; use crate::dsl::FieldArg; -#[cgp_new_provider] -impl UrlArgExtractor for ExtractStringUrlArg +#[cgp_impl(new ExtractStringUrlArg)] +impl UrlArgExtractor for Context where Context: HasUrlType + CanExtractStringArg + CanRaiseError<::Err>, Context::Url: FromStr, @@ -23,8 +23,8 @@ where } } -#[cgp_new_provider] -impl UrlArgExtractor> for ExtractUrlFieldArg +#[cgp_impl(new ExtractUrlFieldArg)] +impl UrlArgExtractor> for Context where Context: HasUrlType + HasErrorType + HasField, Context::Url: Clone, diff --git a/crates/hypershell-components/src/providers/use.rs b/crates/hypershell-components/src/providers/use.rs index 2e9f6cf..91b44d2 100644 --- a/crates/hypershell-components/src/providers/use.rs +++ b/crates/hypershell-components/src/providers/use.rs @@ -5,11 +5,8 @@ use cgp::prelude::*; use crate::dsl::Use; -pub struct HandleUseProvider; - -#[cgp_provider] -impl Handler, Input> - for HandleUseProvider +#[cgp_impl(new HandleUseProvider)] +impl Handler, Input> for Context where Context: HasErrorType, Provider: Handler, diff --git a/crates/hypershell-examples/examples/bluesky.rs b/crates/hypershell-examples/examples/bluesky.rs index bc31447..cd4c2dc 100644 --- a/crates/hypershell-examples/examples/bluesky.rs +++ b/crates/hypershell-examples/examples/bluesky.rs @@ -47,7 +47,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub keyword: String, diff --git a/crates/hypershell-examples/examples/bluesky_websocket.rs b/crates/hypershell-examples/examples/bluesky_websocket.rs index c71877e..b0180fe 100644 --- a/crates/hypershell-examples/examples/bluesky_websocket.rs +++ b/crates/hypershell-examples/examples/bluesky_websocket.rs @@ -46,7 +46,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: MyAppPreset)] +#[cgp_inherit(MyAppPreset)] #[derive(HasField)] pub struct MyApp { pub keyword: String, diff --git a/crates/hypershell-examples/examples/compare_and_branch.rs b/crates/hypershell-examples/examples/compare_and_branch.rs index 34fd8d6..6acc571 100644 --- a/crates/hypershell-examples/examples/compare_and_branch.rs +++ b/crates/hypershell-examples/examples/compare_and_branch.rs @@ -39,7 +39,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellComparePreset)] +#[cgp_inherit(HypershellComparePreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/examples/github_issues.rs b/crates/hypershell-examples/examples/github_issues.rs index c294688..6198f63 100644 --- a/crates/hypershell-examples/examples/github_issues.rs +++ b/crates/hypershell-examples/examples/github_issues.rs @@ -18,7 +18,7 @@ // the JSON byte stream into a `Vec`. // // The `MyApp` struct defines the context for running the Hypershell program. -// It uses `#[cgp_context]` to inherit the necessary components from +// It uses `#[cgp_inherit]` to inherit the necessary components from // `HypershellPreset` for executing the program. It also uses `#[derive(HasField)]` // to expose its fields to be used by `FieldArg` within the program definition. // @@ -51,7 +51,7 @@ pub type Program = hypershell! { | DecodeJson> }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/examples/hello_name.rs b/crates/hypershell-examples/examples/hello_name.rs index c190c71..4d68abe 100644 --- a/crates/hypershell-examples/examples/hello_name.rs +++ b/crates/hypershell-examples/examples/hello_name.rs @@ -18,7 +18,7 @@ // 5. The output is piped to `StreamToStdout`. // // To provide the dynamic `name` argument, a custom `MyApp` context is defined -// with a `name` field. The `#[cgp_context]` macro wires it up with the +// with a `name` field. The `#[cgp_inherit]` macro wires it up with the // `HypershellPreset`, and `#[derive(HasField)]` makes its fields accessible // to `FieldArg`. // @@ -38,7 +38,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub name: String, diff --git a/crates/hypershell-examples/examples/http_checksum_cli.rs b/crates/hypershell-examples/examples/http_checksum_cli.rs index 4b21266..0b2a568 100644 --- a/crates/hypershell-examples/examples/http_checksum_cli.rs +++ b/crates/hypershell-examples/examples/http_checksum_cli.rs @@ -51,7 +51,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub url: String, diff --git a/crates/hypershell-examples/examples/http_checksum_client.rs b/crates/hypershell-examples/examples/http_checksum_client.rs index 9b81814..de23b81 100644 --- a/crates/hypershell-examples/examples/http_checksum_client.rs +++ b/crates/hypershell-examples/examples/http_checksum_client.rs @@ -51,7 +51,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/examples/http_checksum_native.rs b/crates/hypershell-examples/examples/http_checksum_native.rs index fb329b1..5a78768 100644 --- a/crates/hypershell-examples/examples/http_checksum_native.rs +++ b/crates/hypershell-examples/examples/http_checksum_native.rs @@ -47,7 +47,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellChecksumPreset)] +#[cgp_inherit(HypershellChecksumPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/examples/nix_manual.rs b/crates/hypershell-examples/examples/nix_manual.rs index b6518e4..ff7f472 100644 --- a/crates/hypershell-examples/examples/nix_manual.rs +++ b/crates/hypershell-examples/examples/nix_manual.rs @@ -51,7 +51,7 @@ pub type Program = hypershell! { | StreamToStdout }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/examples/parallel_compare.rs b/crates/hypershell-examples/examples/parallel_compare.rs index 6551bae..4f9ccef 100644 --- a/crates/hypershell-examples/examples/parallel_compare.rs +++ b/crates/hypershell-examples/examples/parallel_compare.rs @@ -24,7 +24,7 @@ pub type Program = hypershell! { > }; -#[cgp_context(MyAppComponents: HypershellComparePreset)] +#[cgp_inherit(HypershellComparePreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/examples/save_webpage.rs b/crates/hypershell-examples/examples/save_webpage.rs index 13ca62a..4c0d0b5 100644 --- a/crates/hypershell-examples/examples/save_webpage.rs +++ b/crates/hypershell-examples/examples/save_webpage.rs @@ -31,7 +31,7 @@ pub type Program = hypershell! { | WriteFile> }; -#[cgp_context(MyAppComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct MyApp { pub http_client: Client, diff --git a/crates/hypershell-examples/src/providers/compare.rs b/crates/hypershell-examples/src/providers/compare.rs index dc4f72b..752e946 100644 --- a/crates/hypershell-examples/src/providers/compare.rs +++ b/crates/hypershell-examples/src/providers/compare.rs @@ -6,9 +6,9 @@ use hypershell::prelude::CanHandle; use crate::dsl::Compare; -#[cgp_new_provider] -impl - Handler, (InputA, InputB)> for HandleCompare +#[cgp_impl(new HandleCompare)] +impl Handler, (InputA, InputB)> + for Context where Context: CanHandle + CanHandle, Output: Eq, diff --git a/crates/hypershell-examples/src/providers/if.rs b/crates/hypershell-examples/src/providers/if.rs index b252543..f4d939b 100644 --- a/crates/hypershell-examples/src/providers/if.rs +++ b/crates/hypershell-examples/src/providers/if.rs @@ -6,9 +6,9 @@ use hypershell::prelude::CanHandle; use crate::dsl::If; -#[cgp_new_provider] +#[cgp_impl(new HandleIf)] impl - Handler, (InputCond, InputBranch)> for HandleIf + Handler, (InputCond, InputBranch)> for Context where Context: CanHandle + CanHandle diff --git a/crates/hypershell-examples/tests/tests/field.rs b/crates/hypershell-examples/tests/tests/field.rs index 9706173..dd10c1b 100644 --- a/crates/hypershell-examples/tests/tests/field.rs +++ b/crates/hypershell-examples/tests/tests/field.rs @@ -3,7 +3,7 @@ use hypershell::presets::HypershellPreset; #[tokio::test] async fn test_join_fields() -> Result<(), Error> { - #[cgp_context(TestAppComponents: HypershellPreset)] + #[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct TestApp { pub base_dir: String, @@ -36,7 +36,7 @@ async fn test_join_fields() -> Result<(), Error> { #[tokio::test] async fn test_field_args() -> Result<(), Error> { - #[cgp_context(TestAppComponents: HypershellPreset)] + #[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct TestApp<'a> { pub args: Vec<&'a str>, diff --git a/crates/hypershell-examples/tests/tests/pipe.rs b/crates/hypershell-examples/tests/tests/pipe.rs index 54c7068..60a6fa3 100644 --- a/crates/hypershell-examples/tests/tests/pipe.rs +++ b/crates/hypershell-examples/tests/tests/pipe.rs @@ -3,7 +3,7 @@ use hypershell::presets::HypershellPreset; #[tokio::test] async fn test_simple_pipe() -> Result<(), Error> { - #[cgp_context(TestAppComponents: HypershellPreset)] + #[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct TestApp { pub base_dir: String, diff --git a/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs b/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs index ac5bc34..097d43a 100644 --- a/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs +++ b/crates/hypershell-hash-components/src/providers/bytes_to_hex.rs @@ -3,8 +3,8 @@ use core::marker::PhantomData; use cgp::extra::handler::{Handler, HandlerComponent}; use cgp::prelude::*; -#[cgp_new_provider] -impl Handler for HandleBytesToHex +#[cgp_impl(new HandleBytesToHex)] +impl Handler for Context where Context: HasErrorType, Input: AsRef<[u8]>, diff --git a/crates/hypershell-hash-components/src/providers/stream_checksum.rs b/crates/hypershell-hash-components/src/providers/stream_checksum.rs index 8646938..9b9b5fe 100644 --- a/crates/hypershell-hash-components/src/providers/stream_checksum.rs +++ b/crates/hypershell-hash-components/src/providers/stream_checksum.rs @@ -8,8 +8,8 @@ use sha2::digest::generic_array::GenericArray; use crate::dsl::Checksum; -#[cgp_new_provider] -impl Handler, Input> for HandleStreamChecksum +#[cgp_impl(new HandleStreamChecksum)] +impl Handler, Input> for Context where Context: CanRaiseError, Input: Unpin + TryStream, diff --git a/crates/hypershell-json-components/src/providers/handler.rs b/crates/hypershell-json-components/src/providers/handler.rs index dea3fe4..2b25b0a 100644 --- a/crates/hypershell-json-components/src/providers/handler.rs +++ b/crates/hypershell-json-components/src/providers/handler.rs @@ -7,8 +7,8 @@ use hypershell_components::dsl::DecodeJson; use serde::Serialize; use serde::de::DeserializeOwned; -#[cgp_new_provider] -impl Handler, Input> for HandleDecodeJson +#[cgp_impl(new HandleDecodeJson)] +impl Handler, Input> for Context where Context: CanRaiseError, Input: AsRef<[u8]>, @@ -26,8 +26,8 @@ where } } -#[cgp_new_provider] -impl Handler for HandleEncodeJson +#[cgp_impl(new HandleEncodeJson)] +impl Handler for Context where Context: CanRaiseError, Input: Serialize, diff --git a/crates/hypershell-reqwest-components/src/providers/convert.rs b/crates/hypershell-reqwest-components/src/providers/convert.rs index 35866ce..7fdcb47 100644 --- a/crates/hypershell-reqwest-components/src/providers/convert.rs +++ b/crates/hypershell-reqwest-components/src/providers/convert.rs @@ -6,8 +6,8 @@ use reqwest::Body; use tokio::io::AsyncRead; use tokio_util::io::ReaderStream; -#[cgp_new_provider] -impl Handler for StreamToBody +#[cgp_impl(new StreamToBody)] +impl Handler for Context where Context: HasErrorType, Input: Send + AsyncRead + 'static, diff --git a/crates/hypershell-reqwest-components/src/providers/core_request.rs b/crates/hypershell-reqwest-components/src/providers/core_request.rs index 32c3582..bbbd5c7 100644 --- a/crates/hypershell-reqwest-components/src/providers/core_request.rs +++ b/crates/hypershell-reqwest-components/src/providers/core_request.rs @@ -8,9 +8,9 @@ use reqwest::{Body, Method, Response, Url}; use crate::components::{CanUpdateRequestBuilder, HasReqwestClient}; use crate::dsl::CoreHttpRequest; -#[cgp_new_provider] +#[cgp_impl(new HandleCoreHttpRequest)] impl - Handler, Input> for HandleCoreHttpRequest + Handler, Input> for Context where Context: HasReqwestClient + CanExtractUrlArg diff --git a/crates/hypershell-reqwest-components/src/providers/headers.rs b/crates/hypershell-reqwest-components/src/providers/headers.rs index d97bef8..4978cc2 100644 --- a/crates/hypershell-reqwest-components/src/providers/headers.rs +++ b/crates/hypershell-reqwest-components/src/providers/headers.rs @@ -10,8 +10,8 @@ use crate::components::{ CanUpdateRequestBuilder, RequestBuilderUpdater, RequestBuilderUpdaterComponent, }; -#[cgp_new_provider] -impl RequestBuilderUpdater> for UpdateRequestHeader +#[cgp_impl(new UpdateRequestHeader)] +impl RequestBuilderUpdater> for Context where Context: CanExtractStringArg + CanExtractStringArg @@ -36,12 +36,11 @@ where pub struct UpdateRequestHeaders; -#[cgp_provider] -impl RequestBuilderUpdater>> - for UpdateRequestHeaders +#[cgp_impl(UpdateRequestHeaders)] +impl RequestBuilderUpdater>> for Context where Context: CanUpdateRequestBuilder, - Self: RequestBuilderUpdater>, + UpdateRequestHeaders: RequestBuilderUpdater>, { fn update_request_builder( context: &Context, @@ -49,15 +48,18 @@ where builder: RequestBuilder, ) -> Result { let builder = context.update_request_builder(PhantomData, builder)?; - let builder = - Self::update_request_builder(context, PhantomData::>, builder)?; + let builder = UpdateRequestHeaders::update_request_builder( + context, + PhantomData::>, + builder, + )?; Ok(builder) } } -#[cgp_provider] -impl RequestBuilderUpdater> for UpdateRequestHeaders +#[cgp_impl(UpdateRequestHeaders)] +impl RequestBuilderUpdater> for Context where Context: HasErrorType, { diff --git a/crates/hypershell-reqwest-components/src/providers/method_arg.rs b/crates/hypershell-reqwest-components/src/providers/method_arg.rs index 29221fe..c746f64 100644 --- a/crates/hypershell-reqwest-components/src/providers/method_arg.rs +++ b/crates/hypershell-reqwest-components/src/providers/method_arg.rs @@ -9,8 +9,8 @@ use reqwest::Method; pub struct ExtractReqwestMethod; -#[cgp_provider] -impl MethodArgExtractor for ExtractReqwestMethod +#[cgp_impl(ExtractReqwestMethod)] +impl MethodArgExtractor for Context where Context: HasHttpMethodType, { @@ -19,8 +19,8 @@ where } } -#[cgp_provider] -impl MethodArgExtractor for ExtractReqwestMethod +#[cgp_impl(ExtractReqwestMethod)] +impl MethodArgExtractor for Context where Context: HasHttpMethodType, { @@ -29,8 +29,8 @@ where } } -#[cgp_provider] -impl MethodArgExtractor for ExtractReqwestMethod +#[cgp_impl(ExtractReqwestMethod)] +impl MethodArgExtractor for Context where Context: HasHttpMethodType, { @@ -39,8 +39,8 @@ where } } -#[cgp_provider] -impl MethodArgExtractor for ExtractReqwestMethod +#[cgp_impl(ExtractReqwestMethod)] +impl MethodArgExtractor for Context where Context: HasHttpMethodType, { diff --git a/crates/hypershell-reqwest-components/src/providers/simple_request.rs b/crates/hypershell-reqwest-components/src/providers/simple_request.rs index 87b9341..0bac57a 100644 --- a/crates/hypershell-reqwest-components/src/providers/simple_request.rs +++ b/crates/hypershell-reqwest-components/src/providers/simple_request.rs @@ -12,10 +12,9 @@ pub struct ErrorResponse { pub response: Response, } -#[cgp_new_provider] +#[cgp_impl(new HandleSimpleHttpRequest)] impl - Handler, Input> - for HandleSimpleHttpRequest + Handler, Input> for Context where Context: CanHandle, Input, Output = Response> + CanRaiseError diff --git a/crates/hypershell-reqwest-components/src/providers/streaming_request.rs b/crates/hypershell-reqwest-components/src/providers/streaming_request.rs index 3794eb7..4c2df6e 100644 --- a/crates/hypershell-reqwest-components/src/providers/streaming_request.rs +++ b/crates/hypershell-reqwest-components/src/providers/streaming_request.rs @@ -10,10 +10,9 @@ use reqwest::Response; use crate::dsl::CoreHttpRequest; use crate::providers::ErrorResponse; -#[cgp_new_provider] +#[cgp_impl(new HandleStreamingHttpRequest)] impl - Handler, Input> - for HandleStreamingHttpRequest + Handler, Input> for Context where Context: CanHandle, Input, Output = Response> + CanRaiseError diff --git a/crates/hypershell-reqwest-components/src/providers/url_encode.rs b/crates/hypershell-reqwest-components/src/providers/url_encode.rs index 835296b..204e988 100644 --- a/crates/hypershell-reqwest-components/src/providers/url_encode.rs +++ b/crates/hypershell-reqwest-components/src/providers/url_encode.rs @@ -8,8 +8,8 @@ use hypershell_components::components::{ use hypershell_components::dsl::UrlEncodeArg; use url::form_urlencoded; -#[cgp_new_provider] -impl StringArgExtractor> for UrlEncodeStringArg +#[cgp_impl(new UrlEncodeStringArg)] +impl StringArgExtractor> for Context where Context: CanExtractStringArg, { diff --git a/crates/hypershell-tokio-components/src/providers/core_exec.rs b/crates/hypershell-tokio-components/src/providers/core_exec.rs index eff539f..b6c79a7 100644 --- a/crates/hypershell-tokio-components/src/providers/core_exec.rs +++ b/crates/hypershell-tokio-components/src/providers/core_exec.rs @@ -13,9 +13,8 @@ use tokio::process::{Child, Command}; use crate::components::CanUpdateCommand; use crate::dsl::CoreExec; -#[cgp_new_provider] -impl Handler, ()> - for HandleCoreExec +#[cgp_impl(new HandleCoreExec)] +impl Handler, ()> for Context where Context: HasErrorType + CanExtractCommandArg diff --git a/crates/hypershell-tokio-components/src/providers/file.rs b/crates/hypershell-tokio-components/src/providers/file.rs index c77ba99..e209594 100644 --- a/crates/hypershell-tokio-components/src/providers/file.rs +++ b/crates/hypershell-tokio-components/src/providers/file.rs @@ -8,8 +8,8 @@ use hypershell_components::dsl::{ReadFile, WriteFile}; use tokio::fs::File; use tokio::io::AsyncRead; -#[cgp_new_provider] -impl Handler, ()> for HandleReadFile +#[cgp_impl(new HandleReadFile)] +impl Handler, ()> for Context where Context: CanExtractCommandArg + CanRaiseError, Context::CommandArg: AsRef, @@ -31,8 +31,8 @@ where } } -#[cgp_new_provider] -impl Handler, Input> for HandleWriteFile +#[cgp_impl(new HandleWriteFile)] +impl Handler, Input> for Context where Context: CanExtractCommandArg + CanRaiseError, Context::CommandArg: AsRef, diff --git a/crates/hypershell-tokio-components/src/providers/join_args.rs b/crates/hypershell-tokio-components/src/providers/join_args.rs index 229c073..0f1d438 100644 --- a/crates/hypershell-tokio-components/src/providers/join_args.rs +++ b/crates/hypershell-tokio-components/src/providers/join_args.rs @@ -9,18 +9,18 @@ use hypershell_components::dsl::JoinArgs; pub struct JoinExtractArgs; -#[cgp_provider] -impl CommandArgExtractor>> for JoinExtractArgs +#[cgp_impl(JoinExtractArgs)] +impl CommandArgExtractor>> for Context where Context: CanExtractCommandArg + HasCommandArgType, - Self: CommandArgExtractor>, + JoinExtractArgs: CommandArgExtractor>, { fn extract_command_arg( context: &Context, _phantom: PhantomData>>, ) -> PathBuf { let arg_a = context.extract_command_arg(PhantomData); - let arg_b = Self::extract_command_arg(context, PhantomData::>); + let arg_b = JoinExtractArgs::extract_command_arg(context, PhantomData::>); if arg_b.as_os_str().is_empty() { arg_a @@ -30,8 +30,8 @@ where } } -#[cgp_provider] -impl CommandArgExtractor> for JoinExtractArgs +#[cgp_impl(JoinExtractArgs)] +impl CommandArgExtractor> for Context where Context: HasCommandArgType, { diff --git a/crates/hypershell-tokio-components/src/providers/line.rs b/crates/hypershell-tokio-components/src/providers/line.rs index 4b17da1..70ae723 100644 --- a/crates/hypershell-tokio-components/src/providers/line.rs +++ b/crates/hypershell-tokio-components/src/providers/line.rs @@ -7,8 +7,8 @@ use hypershell_components::dsl::StreamToLines; use tokio::io::AsyncRead; use tokio_util::codec::{FramedRead, LinesCodec, LinesCodecError}; -#[cgp_new_provider] -impl Handler for HandleStreamToLines +#[cgp_impl(new HandleStreamToLines)] +impl Handler for Context where Context: HasErrorType, Input: AsyncRead + Unpin + 'static, diff --git a/crates/hypershell-tokio-components/src/providers/out.rs b/crates/hypershell-tokio-components/src/providers/out.rs index 2fc5539..457facd 100644 --- a/crates/hypershell-tokio-components/src/providers/out.rs +++ b/crates/hypershell-tokio-components/src/providers/out.rs @@ -5,8 +5,8 @@ use cgp::prelude::*; use hypershell_components::dsl::StreamToStdout; use tokio::io::{AsyncRead, copy}; -#[cgp_new_provider] -impl Handler for HandleStreamToStdout +#[cgp_impl(new HandleStreamToStdout)] +impl Handler for Context where Context: CanRaiseError, Input: AsyncRead + Unpin, diff --git a/crates/hypershell-tokio-components/src/providers/simple_exec.rs b/crates/hypershell-tokio-components/src/providers/simple_exec.rs index 5c5100f..899a8a5 100644 --- a/crates/hypershell-tokio-components/src/providers/simple_exec.rs +++ b/crates/hypershell-tokio-components/src/providers/simple_exec.rs @@ -14,9 +14,8 @@ pub struct ExecOutputError { pub output: Output, } -#[cgp_new_provider] -impl Handler, Input> - for HandleSimpleExec +#[cgp_impl(new HandleSimpleExec)] +impl Handler, Input> for Context where Context: CanHandle, (), Output = Child> + for<'a> CanRaiseError diff --git a/crates/hypershell-tokio-components/src/providers/stream.rs b/crates/hypershell-tokio-components/src/providers/stream.rs index 2cf292c..c74b9c5 100644 --- a/crates/hypershell-tokio-components/src/providers/stream.rs +++ b/crates/hypershell-tokio-components/src/providers/stream.rs @@ -13,8 +13,8 @@ use tokio_util::io::ReaderStream; use crate::types::{FuturesAsyncReadStream, FuturesStream, TokioAsyncReadStream}; -#[cgp_new_provider] -impl Handler for HandleTokioAsyncReadToBytes +#[cgp_impl(new HandleTokioAsyncReadToBytes)] +impl Handler for Context where Context: CanRaiseError, Input: TokioAsyncRead + Unpin, @@ -37,8 +37,8 @@ where } } -#[cgp_new_provider] -impl Handler for HandleTokioAsyncReadToString +#[cgp_impl(new HandleTokioAsyncReadToString)] +impl Handler for Context where Context: CanRaiseError, Input: TokioAsyncRead + Unpin, @@ -61,8 +61,8 @@ where } } -#[cgp_new_provider] -impl Handler for HandleBytesToTokioAsyncRead +#[cgp_impl(new HandleBytesToTokioAsyncRead)] +impl Handler for Context where Context: CanRaiseError, Input: AsRef<[u8]> + Unpin, @@ -78,8 +78,8 @@ where } } -#[cgp_new_provider] -impl Handler for HandleBytesToStream +#[cgp_impl(new HandleBytesToStream)] +impl Handler for Context where Context: CanRaiseError, Input: AsRef<[u8]> + Unpin, @@ -95,8 +95,8 @@ where } } -#[cgp_new_provider] -impl Handler for FuturesToTokioAsyncRead +#[cgp_impl(new FuturesToTokioAsyncRead)] +impl Handler for Context where Context: HasErrorType, Input: FuturesAsyncRead + Unpin, @@ -112,8 +112,8 @@ where } } -#[cgp_new_provider] -impl Handler for TokioToFuturesAsyncRead +#[cgp_impl(new TokioToFuturesAsyncRead)] +impl Handler for Context where Context: HasErrorType, Input: TokioAsyncRead + Unpin, @@ -129,8 +129,8 @@ where } } -#[cgp_new_provider] -impl Handler for WrapTokioAsyncRead +#[cgp_impl(new WrapTokioAsyncRead)] +impl Handler for Context where Context: HasErrorType, Input: TokioAsyncRead + Unpin, @@ -146,8 +146,8 @@ where } } -#[cgp_new_provider] -impl Handler for WrapFuturesAsyncRead +#[cgp_impl(new WrapFuturesAsyncRead)] +impl Handler for Context where Context: HasErrorType, Input: FuturesAsyncRead + Unpin, @@ -163,8 +163,8 @@ where } } -#[cgp_new_provider] -impl Handler for AsyncReadToStream +#[cgp_impl(new AsyncReadToStream)] +impl Handler for Context where Context: HasErrorType, Input: TokioAsyncRead + Unpin, diff --git a/crates/hypershell-tokio-components/src/providers/streaming_exec.rs b/crates/hypershell-tokio-components/src/providers/streaming_exec.rs index 8dfea43..373c392 100644 --- a/crates/hypershell-tokio-components/src/providers/streaming_exec.rs +++ b/crates/hypershell-tokio-components/src/providers/streaming_exec.rs @@ -10,9 +10,8 @@ use tokio_util::either::Either; use crate::dsl::CoreExec; -#[cgp_new_provider] -impl Handler, Input> - for HandleStreamingExec +#[cgp_impl(new HandleStreamingExec)] +impl Handler, Input> for Context where Context: CanHandle, (), Output = Child> + CanRaiseError, diff --git a/crates/hypershell-tokio-components/src/providers/update_command.rs b/crates/hypershell-tokio-components/src/providers/update_command.rs index e528f59..93a9a71 100644 --- a/crates/hypershell-tokio-components/src/providers/update_command.rs +++ b/crates/hypershell-tokio-components/src/providers/update_command.rs @@ -10,8 +10,8 @@ use crate::components::{CommandUpdater, CommandUpdaterComponent}; pub struct ExtractArgs; -#[cgp_provider] -impl CommandUpdater>> for ExtractArgs +#[cgp_impl(ExtractArgs)] +impl CommandUpdater>> for Context where Context: CanExtractCommandArg, Context::CommandArg: AsRef + Send, @@ -29,8 +29,8 @@ where } } -#[cgp_provider] -impl CommandUpdater> for ExtractArgs { +#[cgp_impl(ExtractArgs)] +impl CommandUpdater> for Context { fn update_command( _context: &Context, _phantom: PhantomData>, @@ -39,8 +39,8 @@ impl CommandUpdater> for ExtractArgs { } } -#[cgp_new_provider] -impl CommandUpdater> for ExtractFieldArgs +#[cgp_impl(new ExtractFieldArgs)] +impl CommandUpdater> for Context where Context: HasField, for<'a> &'a Context::Value: IntoIterator>, diff --git a/crates/hypershell-tungstenite-components/src/providers/websocket.rs b/crates/hypershell-tungstenite-components/src/providers/websocket.rs index 31ce2ea..b0b0f96 100644 --- a/crates/hypershell-tungstenite-components/src/providers/websocket.rs +++ b/crates/hypershell-tungstenite-components/src/providers/websocket.rs @@ -14,9 +14,8 @@ use tokio_tungstenite::{connect_async, tungstenite}; use tokio_util::bytes::Bytes; use tokio_util::io::ReaderStream; -#[cgp_new_provider] -impl Handler, Input> - for HandleWebsocket +#[cgp_impl(new HandleWebsocket)] +impl Handler, Input> for Context where Context: CanExtractStringArg + CanRaiseError, Input: Send + AsyncRead + Unpin + 'static, diff --git a/crates/hypershell/src/contexts/cli.rs b/crates/hypershell/src/contexts/cli.rs index 3accc28..f4f33f7 100644 --- a/crates/hypershell/src/contexts/cli.rs +++ b/crates/hypershell/src/contexts/cli.rs @@ -2,5 +2,5 @@ use cgp::prelude::*; use crate::presets::HypershellPreset; -#[cgp_context(HypershellCliComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] pub struct HypershellCli; diff --git a/crates/hypershell/src/contexts/http.rs b/crates/hypershell/src/contexts/http.rs index f62a134..6ac5404 100644 --- a/crates/hypershell/src/contexts/http.rs +++ b/crates/hypershell/src/contexts/http.rs @@ -3,7 +3,7 @@ use reqwest::Client; use crate::presets::HypershellPreset; -#[cgp_context(HypershellHttpComponents: HypershellPreset)] +#[cgp_inherit(HypershellPreset)] #[derive(HasField)] pub struct HypershellHttp { pub http_client: Client,