@@ -3,7 +3,27 @@ use quote::quote;
33
44const WIT_PATH : & str = concat ! ( env!( "CARGO_MANIFEST_DIR" ) , "/wit" ) ;
55
6- /// Generates the entrypoint to a Spin Redis component written in Rust.
6+ /// The entrypoint to a Spin Redis component.
7+ ///
8+ /// The component runs in response to messages on a Redis queue.
9+ ///
10+ /// # Examples
11+ ///
12+ /// A handler that logs the content of each message it receives.
13+ ///
14+ /// ```no_run
15+ /// # use anyhow::Result;
16+ /// # use bytes::Bytes;
17+ /// # use spin_sdk::redis_component;
18+ /// # use std::str::from_utf8;
19+ /// #[redis_component]
20+ /// fn on_message(message: Bytes) -> Result<()> {
21+ /// println!("{}", from_utf8(&message)?);
22+ /// Ok(())
23+ /// }
24+ /// ```
25+ ///
26+ /// See <https://spinframework.dev/redis-trigger> for more information.
727#[ proc_macro_attribute]
828pub fn redis_component ( _attr : TokenStream , item : TokenStream ) -> TokenStream {
929 let func = syn:: parse_macro_input!( item as syn:: ItemFn ) ;
@@ -35,7 +55,10 @@ pub fn redis_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
3555 . into ( )
3656}
3757
38- /// The entrypoint to a WASI HTTP component written in Rust.
58+ /// The entrypoint to an HTTP component.
59+ ///
60+ /// The component runs in response to inbound HTTP requests that match the component's
61+ /// trigger.
3962///
4063/// Functions annotated with this attribute can be of two forms:
4164/// * Request/Response
@@ -55,7 +78,7 @@ pub fn redis_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
5578/// `spin_sdk::http::Response`, and even the `http` crate's `Response` type.
5679///
5780/// For example:
58- /// ```ignore
81+ /// ```no_run
5982/// use spin_sdk::http_component;
6083/// use spin_sdk::http::{Request, IntoResponse};
6184///
@@ -76,7 +99,7 @@ pub fn redis_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
7699///
77100/// For example:
78101///
79- /// ```ignore
102+ /// ```no_run
80103/// use spin_sdk::http_component;
81104/// use spin_sdk::http::{IncomingRequest, ResponseOutparam};
82105///
@@ -85,6 +108,8 @@ pub fn redis_component(_attr: TokenStream, item: TokenStream) -> TokenStream {
85108/// // Your logic goes here
86109/// }
87110/// ```
111+ ///
112+ /// See <https://spinframework.dev/http-trigger> for more information.
88113#[ proc_macro_attribute]
89114pub fn http_component ( _attr : TokenStream , item : TokenStream ) -> TokenStream {
90115 let func = syn:: parse_macro_input!( item as syn:: ItemFn ) ;
0 commit comments