[][src]Derive Macro uniui_gui_macro::DataProcessor

#[derive(DataProcessor)]
{
    // Attributes available to this derive:
    #[public_slot]
    #[public_signal]
    #[uprocess_self]
    #[uprocess_each]
    #[uprocess_last]
    #[uprocess_each_app]
    #[uprocess_last_app]
    #[uproperty_process]
    #[uproperty_public_slot]
    #[uproperty_public_signal]
    #[data_processor]
}

DataProcessor derive macro

The DataProcessor trait will be automatically implemented for the structure.

There is few attributes which will help you to configure the implementation.

#[public_slot]

Structure's private member which implements [uniui_core::Slot] trait may be that attribute. Then new method will be generated with the same name as memeber's name. The method will give public access to the member as &dyn Slot.

Example:

mod string_processor {
    #[derive(uniui_gui::DataProcessor)]
    pub struct StringProcessor {
        #[public_slot]
        slot_process_string: uniui_core::SlotImpl<String>,
    }

    // That kind of code will be generated automatically by derive macos:
    //
    // impl StringProcessor {
    //     pub fn slot_process_string(&self) -> &dyn Slot<String> {
    //         return &self.slot_process_string;
    //     }
    // }
}

// Usage:

use string_processor::StringProcessor;

fn send_empty_string(string_processor: StringProcessor, s: String) {
    let slot: &dyn Slot<String> = string_processor.slot_process_string();
    slot.exec_for(s);
}

#[public_signal]

Makes public method to access structure's member of [uniui_core::Signal] type.

#[uprocess_self(<method_name>)]

The structure itself may be marked by the attribute. Structure's method should be provided as parameter to attribue. Then the method will be called every tick (see [uniui_gui::Application] for more info about ticks).

#[uprocess_each(<method_name>)]

Structure's [uniui_core::SlotImpl] may be marked. Then each value arrived to the slot will be processed by the method.

#[uprocess_last(<method_name>)]

Structure's [uniui_core::SlotImpl] may be marked. Then each tick the last arrived value will be processed by the method.

#[uprocess_each_app(<method_name>)]

The same as #[uprocess_each] but reference to the [uniui_gui::Application] will be provided as an extra parameter for the method.

#[uprocess_last_app(<method_name>)]

The same as #[uprocess_last] but reference to the [uniui_gui::Application] will be provided as an extra parameter for the method.

#[uproperty_process]

Structure's member of type [uniui_core::Property] may be marked by attribute. Then every tick the member will process all incoming values. The method name may be provided as a parameter of the attribute. Then the method will be called every time (Property)[uniui_core::Property]'s value will be changed.

#[uproperty_public_slot(<method_name>)]

Create public method to access [uniui_core::Property]'s slot. New method with provided name will be generated.

#[uproperty_public_signal(<method_name>)]

Create public method to access [uniui_core::Property]'s signal. New method with provided name will be generated.

#[data_processor]

Structure's member of type DataProcessor may be marked by that attribute. Then the member's process_data method will be called every time when process_data called for the Structure.