github.com/holochain/holochain-proto@v0.1.0-alpha-26.0.20200915073418-5c83169c9b5b/entry_links.go (about) 1 package holochain 2 3 import ( 4 "encoding/json" 5 ) 6 7 const ( 8 DataFormatLinks = "links" 9 ) 10 11 // LinksEntry holds one or more links 12 type LinksEntry struct { 13 Links []Link 14 } 15 16 // Link structure for holding meta tagging of linking entry 17 type Link struct { 18 LinkAction string // StatusAction (either AddAction or DelAction) 19 Base string // hash of entry (perhaps elsewhere) to which we are attaching the link 20 Link string // hash of entry being linked to 21 Tag string // tag 22 } 23 24 func (ae *LinksEntry) ToJSON() (encodedEntry string, err error) { 25 var j []byte 26 j, err = json.Marshal(ae) 27 encodedEntry = string(j) 28 return 29 } 30 31 func LinksEntryFromJSON(j string) (entry LinksEntry, err error) { 32 err = json.Unmarshal([]byte(j), &entry) 33 return 34 }