Skip to main content

Crate announce_core

Crate announce_core 

Source
Expand description

The implementation behind #[announce] and #[derive(Announce)], as plain functions, and the helpers for callbacks and checks. Do not depend on this crate: go through announce, which re-exports the public API as announce::machinery and announce::helper.

A proc-macro crate cannot export functions, so the code behind the macros lives here, in an ordinary library. announce-macros is a thin wrapper around it. The crate name and layout are not a stable interface.

The API of the generation is announce(), derive_announce() and Options (announce::machinery). See their docs, and announce::machinery for how a library uses them. helper is what callbacks and checks use (announce::helper): the parser of the tokens a trampoline sends, and the macros callback! and transformer!.

Modules§

helper
Helpers for proc-macro crates that use announce trampolines: announce::helper.

Macros§

callback
Defines a #[proc_macro] callback that parses its Input and turns syn::Errors into compile errors. The body returns syn::Result<proc_macro2::TokenStream>.
transformer
Defines a transformer: a #[proc_macro] that gets the newest entry as an Entry, rewrites it (the body returns syn::Result<Entry>), and forwards it to the next list element.

Structs§

Check
One check or meta entry of the attribute: path or path(args).
Options
The parsed arguments of #[announce(..)] or of the #[announce(..)] helper attribute of #[derive(Announce)].

Enums§

Layout
How the generated trampoline holds the item (layout = .., advanced).

Constants§

SINGLE_COPY_THRESHOLD
Tokens (delimiters of a group counted) from which layout = auto holds the item once (Layout::Single) instead of copying it into each arm (Layout::Direct), counted on the escaped payload plus META.

Functions§

announce
Does what #[announce(attr)] does to item.
define_repeater
Does what define_repeater!($vis $ident) does: the definition of the repeater trait, as type-leak writes it (type_leak::repeater_definition).
derive_announce
Does what #[derive(Announce)] does to its input.
derive_announce_with
Like derive_announce(), with the options given in code instead of a helper attribute. Any #[announce(..)] attribute on the input is removed and ignored.
finish
What the hidden macro finish! of the announce crate does: the end of the attribute query that #[announce(check, ..)] and the derives send through their checks (see crate::helper::attrs for the protocol).
try_announce
announce() with the error returned as a syn::Error.
try_define_repeater
define_repeater() with the error returned as a syn::Error.
try_derive_announce
derive_announce() with the error returned as a syn::Error.
try_finish
finish() with the error returned as a syn::Error.