func (this *SwitchAccount) Marshal(writer io.Writer) (int, error) { outBytes := 0 hostStr := "" if this.Host != nil { hostStr = this.Host.String() } writer.Write([]byte{byte(len(hostStr))}) outBytes++ if len(hostStr) > 0 { writer.Write([]byte(hostStr)) outBytes += len(hostStr) } writer.Write(this.Port.Bytes()) outBytes += 2 idBytes := this.ID.Bytes() writer.Write(idBytes) outBytes += len(idBytes) writer.Write(this.AlterIds.Bytes()) outBytes += 2 timestamp := this.ValidUntil.Unix() timeBytes := serial.Int64Literal(timestamp).Bytes() writer.Write(timeBytes) outBytes += len(timeBytes) return outBytes, nil }
func (this *SwitchAccount) Marshal(writer io.Writer) (int, error) { idBytes := this.ID.Bytes() timestamp := this.ValidUntil.Unix() timeBytes := serial.Int64Literal(timestamp).Bytes() writer.Write(idBytes) writer.Write(timeBytes) return 24, nil }
func (this Timestamp) Bytes() []byte { return serial.Int64Literal(this).Bytes() }