lang: Add some docs for events
This commit is contained in:
parent
719602e836
commit
f7b92e2e7c
|
@ -3,7 +3,10 @@ extern crate proc_macro;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::parse_macro_input;
|
use syn::parse_macro_input;
|
||||||
|
|
||||||
/// A data structure representing a Solana account.
|
/// The event attribute allows a struct to be used with
|
||||||
|
/// [emit!](./macro.emit.html) so that programs can log significant events in
|
||||||
|
/// their programs that clients can subscribe to. Currently, this macro is for
|
||||||
|
/// structs only.
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn event(
|
pub fn event(
|
||||||
_args: proc_macro::TokenStream,
|
_args: proc_macro::TokenStream,
|
||||||
|
@ -42,6 +45,10 @@ pub fn event(
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates an event in an Anchor program, which can subsequently be subscribed
|
||||||
|
/// to by clients. Calling this method will internally borsh serialize the
|
||||||
|
/// [event](./attr.event.html), base64 encode the bytes, and then add a
|
||||||
|
/// [msg!](../solana_program/macro.msg.html) log to the transaction.
|
||||||
#[proc_macro]
|
#[proc_macro]
|
||||||
pub fn emit(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
pub fn emit(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||||
let data: proc_macro2::TokenStream = input.into();
|
let data: proc_macro2::TokenStream = input.into();
|
||||||
|
|
|
@ -42,6 +42,7 @@ mod sysvar;
|
||||||
mod vec;
|
mod vec;
|
||||||
|
|
||||||
// Internal module used by macros.
|
// Internal module used by macros.
|
||||||
|
#[doc(hidden)]
|
||||||
pub mod __private {
|
pub mod __private {
|
||||||
pub use base64;
|
pub use base64;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue