package atom import ( "encoding/xml" "fmt" "mime" ) type InlineOtherContent struct { XMLName xml.Name `xml:"content"` *CommonAttributes AnyElement any `xml:",chardata"` Type MediaType `xml:"type,attr,omitempty"` } // newInlineOtherContent creates a new InlineOtherContent. It returns a // *InlineOtherContent and an error. func newInlineOtherContent(mediaType string, content any) (*InlineOtherContent, error) { if mediaType, _, err := mime.ParseMediaType(mediaType); err != nil { return nil, fmt.Errorf("media type %v incompatible with inline other content", mediaType) } return &InlineOtherContent{Type: MediaType(mediaType), AnyElement: content}, nil } // isContent checks whether the InlineOtherContent is a Content. It returns a // bool. func (i *InlineOtherContent) isContent() bool { return true } // hasSRC checks whether the InlineOtherContent has a SRC attribute. It returns // a bool. func (i *InlineOtherContent) hasSRC() bool { return false } // getType returns the Type of the InlineOtherContent as a string. func (i *InlineOtherContent) getType() string { return string(i.Type) } // Check checks the InlineOtherContent for incompatibilities with RFC4287. It // returns an error. func (i *InlineOtherContent) Check() error { mediaType := i.getType() if mediaType, _, err := mime.ParseMediaType(mediaType); err != nil { return fmt.Errorf("type attribute %v incompatible with inline other content", mediaType) } if isCompositeMediaType(mediaType) { return fmt.Errorf("type attribute of inline other content %v must not be a composite type", i) } return nil }