MCPcopy
hub / github.com/AlistGo/alist / marshalInterface

Method marshalInterface

server/webdav/internal/xml/marshal.go:806–823  ·  view source on GitHub ↗

marshalInterface marshals a Marshaler interface value.

(val Marshaler, start StartElement)

Source from the content-addressed store, hash-verified

804
805// marshalInterface marshals a Marshaler interface value.
806func (p *printer) marshalInterface(val Marshaler, start StartElement) error {
807 // Push a marker onto the tag stack so that MarshalXML
808 // cannot close the XML tags that it did not open.
809 p.tags = append(p.tags, Name{})
810 n := len(p.tags)
811
812 err := val.MarshalXML(p.encoder, start)
813 if err != nil {
814 return err
815 }
816
817 // Make sure MarshalXML closed all its tags. p.tags[n-1] is the mark.
818 if len(p.tags) > n {
819 return fmt.Errorf("xml: %s.MarshalXML wrote invalid XML: <%s> not closed", receiverType(val), p.tags[len(p.tags)-1].Local)
820 }
821 p.tags = p.tags[:n-1]
822 return nil
823}
824
825// marshalTextInterface marshals a TextMarshaler interface value.
826func (p *printer) marshalTextInterface(val encoding.TextMarshaler, start StartElement) error {

Callers 1

marshalValueMethod · 0.95

Calls 2

receiverTypeFunction · 0.85
MarshalXMLMethod · 0.65

Tested by

no test coverage detected