[][src]Function hdk::api::commit_entry

pub fn commit_entry(entry: &Entry) -> ZomeApiResult<Address>

Attempts to commit an entry to the local source chain. The entry will also be checked against the defined validation rules for that entry type. If the entry type is defined as public, it will also be published to the DHT. Returns either an address of the committed entry, or an error.

Examples




#[derive(Serialize, Deserialize, Debug, DefaultJson)]
pub struct Post {
    content: String,
    date_created: String,
}

pub fn handle_create_post(content: String) -> ZomeApiResult<Address> {

    let post_entry = Entry::App("post".into(), Post{
        content,
        date_created: "now".into(),
    }.into());

   let address = hdk::commit_entry(&post_entry)?;

   Ok(address)

}