Documentation ¶
Overview ¶
Package types defines types that encode values in SOAP requests and responses.
Based on https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v2.0-20200417.pdf pages 58-60.
Date/time formats are based on http://www.w3.org/TR/1998/NOTE-datetime-19980827
Index ¶
- Constants
- func TypeMap() typedesc.TypeMap
- type BinBase64
- type BinHex
- type Boolean
- type Char
- type Date
- type DateTime
- type DateTimeTZ
- type Fixed14_4
- func (v Fixed14_4) Float64() float64
- func (v *Fixed14_4) MarshalText() ([]byte, error)
- func (v Fixed14_4) Parts() (int64, int16)
- func (v *Fixed14_4) SetFloat64(f float64) error
- func (v *Fixed14_4) SetFractional(fracValue int64) error
- func (v *Fixed14_4) SetParts(intPart int64, fracPart int16) error
- func (v *Fixed14_4) String() string
- func (v *Fixed14_4) UnmarshalText(b []byte) error
- type I1
- type I2
- type I4
- type I8
- type R4
- type R8
- type SOAPValue
- type String
- type TZD
- type TimeOfDay
- func (tod TimeOfDay) CheckValid() error
- func (tod *TimeOfDay) MarshalText() ([]byte, error)
- func (tod *TimeOfDay) SetFromDuration(d time.Duration) error
- func (tod *TimeOfDay) SetFromTime(t time.Time)
- func (tod *TimeOfDay) String() string
- func (tod TimeOfDay) ToDuration() time.Duration
- func (tod *TimeOfDay) UnmarshalText(b []byte) error
- type TimeOfDayTZ
- type UI1
- type UI2
- type UI4
- type UI8
- type URI
Constants ¶
const Fixed14_4Denominator = 1e4
const Fixed14_4MaxFrac = Fixed14_4Denominator - 1
const Fixed14_4MaxFractional = 1e18 - 1
const Fixed14_4MaxInteger = 1e14 - 1
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BinBase64 ¶
type BinBase64 []byte
BinBase64 maps []byte to SOAP "bin.base64" type.
func NewBinBase64 ¶
func (*BinBase64) MarshalText ¶
func (*BinBase64) UnmarshalText ¶
type BinHex ¶
type BinHex []byte
BinHex maps []byte to SOAP "bin.hex" type.
func (*BinHex) MarshalText ¶
func (*BinHex) UnmarshalText ¶
type Boolean ¶
type Boolean bool
func NewBoolean ¶
func (*Boolean) MarshalText ¶
func (*Boolean) UnmarshalText ¶
type Char ¶
type Char rune
Char maps rune to SOAP "char" type.
func (*Char) MarshalText ¶
func (*Char) UnmarshalText ¶
type Date ¶
Date maps to the SOAP "date" type. Marshaling and Unmarshalling does *not* check if components are in range.
func DateFromTime ¶
func (Date) CheckValid ¶
CheckValid returns an error if the date components are out of range.
func (*Date) MarshalText ¶
func (*Date) SetFromTime ¶
func (Date) ToTime ¶
ToTime returns a time.Time from the date components, at midnight, and using the given location.
func (*Date) UnmarshalText ¶
type DateTime ¶
DateTime maps to SOAP "dateTime" type.
func DateTimeFromTime ¶
func (*DateTime) MarshalText ¶
func (*DateTime) UnmarshalText ¶
type DateTimeTZ ¶
DateTime maps to SOAP type "dateTime.tz".
func DateTimeTZFromTime ¶
func DateTimeTZFromTime(t time.Time) DateTimeTZ
func (*DateTimeTZ) MarshalText ¶
func (dtz *DateTimeTZ) MarshalText() ([]byte, error)
func (*DateTimeTZ) String ¶
func (dtz *DateTimeTZ) String() string
func (DateTimeTZ) Time ¶
func (dtz DateTimeTZ) Time(defaultLoc *time.Location) time.Time
Time converts `dtz` to time.Time, using defaultLoc as the default location if `dtz` contains no offset information.
func (*DateTimeTZ) UnmarshalText ¶
func (dtz *DateTimeTZ) UnmarshalText(b []byte) error
type Fixed14_4 ¶
type Fixed14_4 struct { // Fractional divided by 1e4 is the fixed point value. Take care setting // this directly, it should only contain values in the range (-1e18, 1e18). Fractional int64 }
Fixed14_4 represents a fixed point number with up to 14 decimal digits before the decimal point (integer part), and up to 4 decimal digits after the decimal point (fractional part).
Corresponds to the SOAP "fixed.14.4" type.
This is a struct to avoid accidentally using the value directly as an integer.
func Fixed14_4FromFloat ¶
Fixed14_4FromFloat creates a Fixed14_4 from a float64. Returns error if the float is outside the range.
func Fixed14_4FromFractional ¶
Fixed14_4FromFractional creates a Fixed14_4 from an integer, where the parameter divided by 1e4 is the fixed point value.
func Fixed14_4FromParts ¶
Fixed14_4FromParts creates a Fixed14_4 from components. Bounds:
- Both intPart and fracPart must have the same sign.
- -1e14 < intPart < 1e14
- -1e4 < fracPart < 1e4
func (*Fixed14_4) MarshalText ¶
func (*Fixed14_4) SetFloat64 ¶
SetFloat64 sets the value of the fixed point number from a float64. Returns error if the float is outside the range.
func (*Fixed14_4) SetFractional ¶
SetFromFractional sets the value of the fixed point number, where fracValue divided by 1e4 is the fixed point value. Unlike setting v.Fractional directly, this checks the value.
func (*Fixed14_4) SetParts ¶
SetFromParts sets the value based on the integer component and the fractional component. Bounds:
- Both intPart and fracPart must have the same sign.
- -1e14 < intPart < 1e14
- -1e4 < fracPart < 1e4
func (*Fixed14_4) UnmarshalText ¶
type SOAPValue ¶
type SOAPValue interface { encoding.TextMarshaler encoding.TextUnmarshaler }
type TZD ¶
type TZD struct { // Offset is the timezone offset in seconds. Note that the SOAP encoding // only encodes precisions up to minutes, this is in seconds for // interoperability with time.Time. Offset int // HasTZ specifies if a timezone offset is specified or not. HasTZ bool }
TZD is a timezone designator. Not a full SOAP time in itself, but used as part of timezone-aware date/time types that are.
func TZDFromTime ¶
type TimeOfDay ¶
TimeOfDay is used in cases where SOAP "time" or "time.tz" is used. It contains non-timezone aware components.
func TimeOfDayFromTime ¶
func (TimeOfDay) CheckValid ¶
IsValid returns true iff v is positive and <= 24 hours. It allows equal to 24 hours as a special case as 24:00:00 is an allowed value by the SOAP type.
func (*TimeOfDay) MarshalText ¶
func (*TimeOfDay) SetFromDuration ¶
Sets components based on duration since midnight.
func (*TimeOfDay) SetFromTime ¶
func (TimeOfDay) ToDuration ¶
Returns duration since midnight.
func (*TimeOfDay) UnmarshalText ¶
type TimeOfDayTZ ¶
type TimeOfDayTZ struct { // Components of the time of day. TimeOfDay TimeOfDay // Timezone designator. TZ TZD }
TimeOfDayTZ maps to the SOAP "time.tz" type.
func (*TimeOfDayTZ) MarshalText ¶
func (todz *TimeOfDayTZ) MarshalText() ([]byte, error)
func (*TimeOfDayTZ) String ¶
func (todz *TimeOfDayTZ) String() string
func (*TimeOfDayTZ) UnmarshalText ¶
func (todz *TimeOfDayTZ) UnmarshalText(b []byte) error
type URI ¶
URI maps *url.URL to SOAP "uri" type.