Add newInlineOtherContent

This commit is contained in:
Jason Streifling 2024-10-15 21:01:40 +02:00
parent 15b74c2675
commit b26d6370f5

View File

@ -1,11 +1,23 @@
package atomfeed
import "errors"
import (
"errors"
"fmt"
"mime"
)
type InlineOtherContent struct {
*CommonAttributes
AnyElement any `xml:"anyelement,omitempty"`
Type MediaType `xml:"type,attr,omitempty"`
AnyElement []*any `xml:"anyelement,omitempty"`
}
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
}
func (i *InlineOtherContent) isContent() bool { return true }