macro_subject_derive
Helper macro to implement a few traits required for a subject.
Traits you still have to implement to get a subject
ObservableObserver(unless using#[rx_delegate_observer_to_destination])SubscriptionLike(unless using#[rx_delegate_subscription_like_to_destination])
Traits Implemented
WithPrimaryCategory: Sets the associated type toPrimaryCategorySubjectObserverInput: Sets the associated typeInto the value of the#[rx_in(...)]attribute, or toNever(Infallible) if missing. Also sets the associatedInErrortype to the value of the#[rx_in_error(...)]attribute, or toNeverif missing.ObservableOutput: Sets the associated typeOutto the value of the#[rx_out(...)]attribute, or toNever(Infallible) if missing. Also sets the associatedOutErrortype to the value of the#[rx_out_error(...)]attribute, or toNeverif missing.UpgradeableObserver: By default. It implementsUpgradeableObserverby wrapping the subject into aObserverSubscriber. This implementation can be opted out with the#[rx_does_not_upgrade_to_observer_subscriber]attribute to provide a manual implementation. Other preset implementations can be used with the#[rx_upgrades_to(...)]attribute.
Attributes
All attributes are prefixed with
rx_for easy auto-complete access.
#[rx_in(...)](optional, default:Never): Defines the input type of the subject#[rx_in_error(...)](optional, default:Never): Defines the input error type of the subject#[rx_out(...)](optional, default:Never): Defines the output type of the subject, usually it's the same as the input type#[rx_out_error(...)](optional, default:Never): Defines the output error type of the subject, usually it's the same as the input error type#[rx_does_not_upgrade_to_observer_subscriber](optional): Opts out the defaultUpgradeableObserverimplementation which just wraps theSubjectin aObserverSubscriberwhen used as a destination for anObservableto prevent upstream from unsubscribing the entireSubject.#[rx_upgrades_to(...)](optional, accepts:self,observer_subscriber): Defines a preset implementation forUpgradeableObserverself: Upgraded version is itself, causing it to be unsubscribed when upstream is unsubscribed when used as an observables destination.observer_subscriber: Upgraded version is itself wrapped inObserverSubscriber, causing it to not be unsubscribed when upstream is unsubscribed when used as an observables destination.
#[rx_delegate_subscription_like_to_destination](optional): Opts into the trivial implementation ofSubscriptionLikewhere the traits methods are just simply called on the field marked as#[destination].#[rx_delegate_observer_to_destination](optional): Opts into the trivial implementation ofObserverwhere the traits methods are just simply called on the field marked as#[destination].
See Also
RxExecutor- Derive macro for Executors.RxObservable- Derive macro for Observables.RxObserver- Derive macro for RxObservers.RxOperator- Derive macro for Operators.RxScheduler- Derive macro for Schedulers.RxSubscriber- Derive macro for Subscribers.RxSubscription- Derive macro for Subscriptions.RxWork- Derive macro for schedulable work.
Expanding the proc macro
In case you want to inspect the output of the proc macro.
If you haven't installed cargo-expand yet, install it first:
Then expand the macro output: