Module hdk_crud::crud::example[][src]

Expand description

Take a look at this module to get a concrete example of what you need to pass the crud! macro, as well as what you’ll get back out of it. Anything that says “NOT GENERATED” is not generated by the crud! macro call, and the rest is It will generate 4 public Zome functions, as well as some inner functions called by those that you can refer to and call elsewhere. The 4 Zome functions in this example would be: create_example, fetch_examples, update_example, and archive_example.

Structs

NOT GENERATED This is our example hdk_entry entry type definition.

This is what is expected by a call to update_example or inner_update_example

Enums

NOT GENERATED A high level signal type to unify all the entry type specific signal types

Constants

This is the &str that can be passed into Path to find all the entries created using these create functions which are linked off of this Path.

Functions

This is the exposed/public Zome function for archiving an entry of this type. This will mark the entry at address as “deleted”. It will no longer be returned by fetch_examples. It will send a signal of this event to all peers returned by the get_peers call given during the macro call to crud! This just calls inner_archive_example with send_signal as true.

NOT GENERATED This handles the conversion from its predefined type to some slightly modified type that it should be sent over the wire as. It is sort of like a pre-signal-fire hook presenting the chance to do type conversion

This is the exposed/public Zome function for creating an entry of this type. This will create an entry and link it off the main Path. It will send a signal of this event to all peers returned by the get_peers call given during the macro call to crud! This just calls inner_create_example with send_signal as true.

This is the exposed/public Zome function for either fetching ALL or a SPECIFIC list of the entries of the type. No signals will be sent as a result of calling this. Notice that it pluralizes the value of $i, the second argument to the crud! macro call. This just calls inner_fetch_examples.

Retrieve the Path for these entry types to which all entries are linked

NOT GENERATED This handles the fetching of a list of peers to which to send signals. In this example it’s an empty list. Your function signature should match this function signature.

This will mark the entry at address as “deleted”. It will no longer be returned by fetch_examples. It can also optionally send a signal of this event (by passing send_signal value true) to all peers returned by the get_peers call given during the macro call to crud! This will be called with send_signal as true by archive_example

This will create an entry and link it off the main Path. It can also optionally send a signal of this event (by passing send_signal value true) to all peers returned by the get_peers call given during the macro call to crud! This will be called with send_signal as true by create_example

This is the exposed/public Zome function for either fetching ALL or a SPECIFIC list of the entries of the type.

This will add an update to an entry. It can also optionally send a signal of this event (by passing send_signal value true) to all peers returned by the get_peers call given during the macro call to crud!

NOT GENERATED Signal Receiver (forwards signals to the UI) would be handling a

This is the exposed/public Zome function for creating an entry of this type. This will add an update to an entry. It will send a signal of this event to all peers returned by the get_peers call given during the macro call to crud! This just calls inner_update_example with send_signal as true.