Skip to content

Commit f7b92e2

Browse files
lang: Add some docs for events
1 parent 719602e commit f7b92e2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lang/attribute/event/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ extern crate proc_macro;
33
use quote::quote;
44
use syn::parse_macro_input;
55

6-
/// A data structure representing a Solana account.
6+
/// The event attribute allows a struct to be used with
7+
/// [emit!](./macro.emit.html) so that programs can log significant events in
8+
/// their programs that clients can subscribe to. Currently, this macro is for
9+
/// structs only.
710
#[proc_macro_attribute]
811
pub fn event(
912
_args: proc_macro::TokenStream,
@@ -42,6 +45,10 @@ pub fn event(
4245
})
4346
}
4447

48+
/// Creates an event in an Anchor program, which can subsequently be subscribed
49+
/// to by clients. Calling this method will internally borsh serialize the
50+
/// [event](./attr.event.html), base64 encode the bytes, and then add a
51+
/// [msg!](../solana_program/macro.msg.html) log to the transaction.
4552
#[proc_macro]
4653
pub fn emit(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
4754
let data: proc_macro2::TokenStream = input.into();

lang/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ mod sysvar;
4242
mod vec;
4343

4444
// Internal module used by macros.
45+
#[doc(hidden)]
4546
pub mod __private {
4647
pub use base64;
4748
}

0 commit comments

Comments
 (0)