atom/inlineOtherContent.go

36 lines
942 B
Go
Raw Normal View History

2024-10-13 17:19:40 +02:00
package atomfeed
2024-10-15 21:01:40 +02:00
import (
"errors"
"fmt"
"mime"
)
2024-10-13 17:19:40 +02:00
type InlineOtherContent struct {
*CommonAttributes
2024-10-15 21:01:40 +02:00
AnyElement any `xml:"anyelement,omitempty"`
2024-10-13 17:19:40 +02:00
Type MediaType `xml:"type,attr,omitempty"`
2024-10-15 21:01:40 +02:00
}
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
2024-10-13 17:19:40 +02:00
}
2024-10-15 19:32:14 +02:00
func (i *InlineOtherContent) isContent() bool { return true }
func (i *InlineOtherContent) hasSRC() bool { return false }
func (i *InlineOtherContent) getType() string { return string(i.Type) }
2024-10-13 17:19:40 +02:00
func (i *InlineOtherContent) Check() error {
if isCompositeMediaType(i.getType()) {
return errors.New("type attribute of inline other content must not be a composite type")
}
return nil
}