mirror of
https://github.com/jwetzell/psn-go.git
synced 2026-09-11 09:09:36 +00:00
move types out of decoders package
This commit is contained in:
@@ -3,23 +3,16 @@ package decoders
|
||||
import (
|
||||
"encoding/binary"
|
||||
"log/slog"
|
||||
|
||||
"github.com/jwetzell/psn-go/internal/chunks"
|
||||
)
|
||||
|
||||
type InfoTrackerChunkData struct {
|
||||
TrackerName *InfoTrackerNameChunk
|
||||
}
|
||||
|
||||
type InfoTrackerChunk struct {
|
||||
Data InfoTrackerChunkData
|
||||
Chunk Chunk
|
||||
}
|
||||
|
||||
func DecodeInfoTrackerChunk(bytes []byte) (InfoTrackerChunk, error) {
|
||||
func DecodeInfoTrackerChunk(bytes []byte) (chunks.InfoTrackerChunk, error) {
|
||||
chunk, err := DecodeChunk(bytes)
|
||||
if err != nil {
|
||||
return InfoTrackerChunk{}, err
|
||||
return chunks.InfoTrackerChunk{}, err
|
||||
}
|
||||
data := InfoTrackerChunkData{}
|
||||
data := chunks.InfoTrackerChunkData{}
|
||||
|
||||
if chunk.Header.HasSubchunks && chunk.ChunkData != nil && chunk.Header.DataLen > 0 {
|
||||
offset := 0
|
||||
@@ -29,7 +22,7 @@ func DecodeInfoTrackerChunk(bytes []byte) (InfoTrackerChunk, error) {
|
||||
case 0x0000:
|
||||
tracker_name, err := DecodeInfoTrackerNameChunk(chunk.ChunkData[offset:])
|
||||
if err != nil {
|
||||
return InfoTrackerChunk{}, err
|
||||
return chunks.InfoTrackerChunk{}, err
|
||||
}
|
||||
data.TrackerName = &tracker_name
|
||||
offset += 4
|
||||
@@ -42,7 +35,7 @@ func DecodeInfoTrackerChunk(bytes []byte) (InfoTrackerChunk, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return InfoTrackerChunk{
|
||||
return chunks.InfoTrackerChunk{
|
||||
Chunk: chunk,
|
||||
Data: data,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user