Derive macros for FromMessage and ToMessage traits from ircv3_parse.
Attributes
When no explicit key is specified, the field name is used as the key, converted to kebab-case.
#[irc(command = "CMD")] is optional for structs and unit structs.
Struct
The container attribute #[irc(command = "CMD")] checks the command on deserialization and writes it on serialization.
Tags
Tag
Tag Flag
Supports bool, Option<T>, or a nested type.
Source
// source.name
Param
// first param (index 0)
// second param
// all params
Vec<T> is only valid with #[irc(params)].
Trailing
&str/Stringnever fails - yields an empty string when absent.Option<T>yieldsNonewhen absent or empty (empty string is treated asNone).
Command
Does not support Option.
Nested
A field with no #[irc(...)] attribute delegates to that type's own FromMessage/ToMessage implementation.
Unit Struct
Unit structs validate that a message matches expected values without extracting data, and write those values on serialization.
;
#[irc(command = "CMD")]- matches/writes the command#[irc(tag = "key")],#[irc(param)], etc. - matches/writes a specific component value#[irc(value = "...")]- overrides the expected value (default: kebab-case of the struct name)
Enum
Enums match a single IRC component value against variant patterns.
Container Attributes
#[irc(rename_all = "lowercase|UPPERCASE|kebab-case")]- rename all variants (default:kebab-case, exceptcommandwhich defaults toUPPERCASE)
When no key is specified, the enum name is used as the tag key (always kebab-case, independent of rename_all).
Variant Attributes
#[irc(value = "...")]- override the match/serialization value (can appear multiple times. seepickfor serialization with multiple values)#[irc(present)]- fortag_flagenums, marks the variant matched when the flag is present
tag_flag enums require exactly two variants:
- one marked
#[irc(present)]- matched when the flag is present - one absent variant - matched when the flag is absent. must be a unit variant
Enum Fields
Variants can carry fields that extract additional IRC components.
When a variant has a single unnamed field with no #[irc(...)] attribute, the field carries the matched component value directly.
Deserialization (FromMessage)
Field Options
with
Provides a custom deserializer function. The function receives the raw component input.
timestamp: u64,
default
Uses a fallback value when the component is absent instead of returning an error.
// Default::default()
// red_fn()
Enum
#[irc(default = "VariantName")]- catch-all unit variant for unrecognized values
Serialization (ToMessage)
Container
#[irc(crlf)]- appends\r\nand validates the message is complete:- command must be set (
#[irc(command = "...")]or#[irc(command)]field) #[irc(source = "user")]or#[irc(source = "host")]requires#[irc(source)]to also be present
- command must be set (
Field Options
skip
Always skip this field during serialization.
skip_none
Skip the tag entirely when the value is None. Only allowed on #[irc(tag)] fields with Option<String> or Option<&str> type.
Without skip_none, None writes key= (tag present with no value). With skip_none, None omits the tag entirely.
id: , // None -> tag absent, Some(v) -> @msgid=v
id: , // None -> @msgid=
Enum Variant
#[irc(pick)]- when a variant has multiple#[irc(value)], selects which one to use for serialization