Documentation
¶
Overview ¶
Package applehealth provides access to Apple Health exported data.
Example ¶
file := filepath.Join("testdata", "testdata.zip")
u, err := NewUnmarshaler(file)
if err != nil {
log.Fatal(err)
}
defer u.Close()
// call Next() once to be able to read metadata
var data healthkit.Data
if data, err = u.Next(); err != nil {
log.Fatal(err)
}
fmt.Printf("Meta: %s\n", u.Meta())
for {
fmt.Printf("Got %T:\n", data)
switch data := data.(type) {
case *healthkit.Record:
fmt.Printf("\t%s\n", data.Type)
}
if data, err = u.Next(); err != nil {
break
}
}
if err != io.EOF {
log.Fatal(err)
}
Output: Meta: {Locale:ru_RU ExportDate:{XMLName:{Space: Local:ExportDate} Value:2019-12-26 08:20:53 +0300} Me:{XMLName:{Space: Local:Me} DateOfBirth:1987-10-02 BiologicalSex:HKBiologicalSexFemale BloodType:HKBloodTypeABPositive FitzpatrickSkinType:HKFitzpatrickSkinTypeVI}} Got *healthkit.Record: HKQuantityTypeIdentifierHeight Got *healthkit.Record: HKQuantityTypeIdentifierBodyMass
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser struct {
DisallowUnhandledElements bool // if true, Next() will return UnhandledElementError for unhandled data
// contains filtered or unexported fields
}
Parser is responsible for parsing Apple Health XML stream.
Most users should use Unmarshaler instead.
func NewParser ¶
NewParser creates a new parser with given XML decoder.
Most users should use NewUnmarshaler instead.
func (*Parser) InputOffset ¶
InputOffset returns XML stream input offset. Unlike calling xml.Decoder.InputOffset directly, that method can be called concurrently with Next().
type UnhandledElementError ¶
type UnhandledElementError struct {
Name string
}
UnhandledElementError is returned by the Parser from the Next() method if DisallowUnhandledElements is true and unhandled data is encountered.
func (*UnhandledElementError) Error ¶
func (u *UnhandledElementError) Error() string
type Unmarshaler ¶
type Unmarshaler struct {
*Parser
// contains filtered or unexported fields
}
Unmarshaler is responsible for parsing Apple Health exported ZIP or XML files.
It embeds Parser as a public field, so Parser's exported methods like Next() and Meta() can be called directly.
func NewUnmarshaler ¶
func NewUnmarshaler(file string) (*Unmarshaler, error)
NewUnmarshaler creates a new Unmarshaler for a given ZIP or XML file.
func (*Unmarshaler) Stats ¶
func (p *Unmarshaler) Stats() Stats
Stats return the current Unmarshaler's statistics.