move types out of decoders package

This commit is contained in:
2025-10-17 15:27:33 -05:00
parent 7dd6d45a08
commit 7b1dc4bfd6
54 changed files with 558 additions and 490 deletions
+7 -14
View File
@@ -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,
},