internal/pipewire: add json struct tags
All checks were successful
Test / Create distribution (push) Successful in 36s
Test / Sandbox (push) Successful in 2m26s
Test / Hakurei (push) Successful in 3m19s
Test / Hpkg (push) Successful in 4m11s
Test / Sandbox (race detector) (push) Successful in 4m23s
Test / Hakurei (race detector) (push) Successful in 5m12s
Test / Flake checks (push) Successful in 1m30s

These match the names found in documentation.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
Ophestra 2025-11-28 01:33:32 +09:00
parent d08a1081bd
commit cbe86dc4f0
Signed by: cat
SSH Key Fingerprint: SHA256:gQ67O0enBZ7UdZypgtspB2FDM1g3GVw8nX0XSdcFw8Q
5 changed files with 36 additions and 36 deletions

View File

@ -39,11 +39,11 @@ const (
// This is emitted when binding to a client or when the client info is updated later. // This is emitted when binding to a client or when the client info is updated later.
type ClientInfo struct { type ClientInfo struct {
// The global id of the client. // The global id of the client.
ID Int ID Int `json:"id"`
// The changes emitted by this event. // The changes emitted by this event.
ChangeMask Long ChangeMask Long `json:"change_mask"`
// Properties of this object, valid when change_mask has PW_CLIENT_CHANGE_MASK_PROPS. // Properties of this object, valid when change_mask has PW_CLIENT_CHANGE_MASK_PROPS.
Props *SPADict Properties *SPADict `json:"props"`
} }
// Size satisfies [KnownSize] with a value computed at runtime. // Size satisfies [KnownSize] with a value computed at runtime.
@ -51,7 +51,7 @@ func (c *ClientInfo) Size() Word {
return SizePrefix + return SizePrefix +
Size(SizeInt) + Size(SizeInt) +
Size(SizeLong) + Size(SizeLong) +
c.Props.Size() c.Properties.Size()
} }
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
@ -62,12 +62,12 @@ func (c *ClientInfo) UnmarshalBinary(data []byte) error { return Unmarshal(data,
// ClientUpdateProperties is used to update the properties of a client. // ClientUpdateProperties is used to update the properties of a client.
type ClientUpdateProperties struct { type ClientUpdateProperties struct {
// Props are properties to update on the client. // Properties to update on the client.
Props *SPADict Properties *SPADict `json:"props"`
} }
// Size satisfies [KnownSize] with a value computed at runtime. // Size satisfies [KnownSize] with a value computed at runtime.
func (c *ClientUpdateProperties) Size() Word { return SizePrefix + c.Props.Size() } func (c *ClientUpdateProperties) Size() Word { return SizePrefix + c.Properties.Size() }
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
func (c *ClientUpdateProperties) MarshalBinary() ([]byte, error) { return Marshal(c) } func (c *ClientUpdateProperties) MarshalBinary() ([]byte, error) { return Marshal(c) }

View File

@ -13,7 +13,7 @@ func TestClientInfo(t *testing.T) {
{"sample", samplePWContainer[1][2][1], pipewire.ClientInfo{ {"sample", samplePWContainer[1][2][1], pipewire.ClientInfo{
ID: 34, ID: 34,
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS, ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
Props: &pipewire.SPADict{ Properties: &pipewire.SPADict{
{Key: "pipewire.protocol", Value: "protocol-native"}, {Key: "pipewire.protocol", Value: "protocol-native"},
{Key: "core.name", Value: "pipewire-0"}, {Key: "core.name", Value: "pipewire-0"},
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"}, {Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
@ -28,7 +28,7 @@ func TestClientInfo(t *testing.T) {
{"sample*", samplePWContainer[1][3][1], pipewire.ClientInfo{ {"sample*", samplePWContainer[1][3][1], pipewire.ClientInfo{
ID: 34, ID: 34,
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS, ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
Props: &pipewire.SPADict{ Properties: &pipewire.SPADict{
{Key: "pipewire.protocol", Value: "protocol-native"}, {Key: "pipewire.protocol", Value: "protocol-native"},
{Key: "core.name", Value: "pipewire-alice-1443"}, {Key: "core.name", Value: "pipewire-alice-1443"},
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"}, {Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
@ -72,7 +72,7 @@ func TestClientInfo(t *testing.T) {
{"sample**", samplePWContainer[1][4][1], pipewire.ClientInfo{ {"sample**", samplePWContainer[1][4][1], pipewire.ClientInfo{
ID: 34, ID: 34,
ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS, ChangeMask: pipewire.PW_CLIENT_CHANGE_MASK_PROPS,
Props: &pipewire.SPADict{ Properties: &pipewire.SPADict{
{Key: "pipewire.protocol", Value: "protocol-native"}, {Key: "pipewire.protocol", Value: "protocol-native"},
{Key: "core.name", Value: "pipewire-alice-1443"}, {Key: "core.name", Value: "pipewire-alice-1443"},
{Key: "pipewire.sec.socket", Value: "pipewire-0-manager"}, {Key: "pipewire.sec.socket", Value: "pipewire-0-manager"},
@ -120,7 +120,7 @@ func TestClientUpdateProperties(t *testing.T) {
t.Parallel() t.Parallel()
encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{ encodingTestCases[pipewire.ClientUpdateProperties, *pipewire.ClientUpdateProperties]{
{"sample", samplePWContainer[0][1][1], pipewire.ClientUpdateProperties{Props: &pipewire.SPADict{ {"sample", samplePWContainer[0][1][1], pipewire.ClientUpdateProperties{Properties: &pipewire.SPADict{
{Key: "remote.intention", Value: "manager"}, {Key: "remote.intention", Value: "manager"},
{Key: "application.name", Value: "pw-container"}, {Key: "application.name", Value: "pw-container"},
{Key: "application.process.binary", Value: "pw-container"}, {Key: "application.process.binary", Value: "pw-container"},

View File

@ -78,28 +78,28 @@ const (
// The server shall include this footer in the next message it sends that // The server shall include this footer in the next message it sends that
// follows the increment of the registry generation number. // follows the increment of the registry generation number.
type FooterCoreGeneration struct { type FooterCoreGeneration struct {
RegistryGeneration Long RegistryGeneration Long `json:"registry_generation"`
} }
// A CoreInfo event is emitted by the server upon connection // A CoreInfo event is emitted by the server upon connection
// with the more information about the server. // with the more information about the server.
type CoreInfo struct { type CoreInfo struct {
// The id of the server (PW_ID_CORE). // The id of the server (PW_ID_CORE).
ID Int ID Int `json:"id"`
// A unique cookie for this server. // A unique cookie for this server.
Cookie Int Cookie Int `json:"cookie"`
// The name of the user running the server. // The name of the user running the server.
UserName String UserName String `json:"user_name"`
// The name of the host running the server. // The name of the host running the server.
HostName String HostName String `json:"host_name"`
// A version string of the server. // A version string of the server.
Version String Version String `json:"version"`
// The name of the server. // The name of the server.
Name String Name String `json:"name"`
// A set of bits with changes to the info. // A set of bits with changes to the info.
ChangeMask Long ChangeMask Long `json:"change_mask"`
// Optional key/value properties, valid when change_mask has PW_CORE_CHANGE_MASK_PROPS. // Optional key/value properties, valid when change_mask has PW_CORE_CHANGE_MASK_PROPS.
Props *SPADict Properties *SPADict `json:"props"`
} }
// Size satisfies [KnownSize] with a value computed at runtime. // Size satisfies [KnownSize] with a value computed at runtime.
@ -112,7 +112,7 @@ func (c *CoreInfo) Size() Word {
SizeString[Word](c.Version) + SizeString[Word](c.Version) +
SizeString[Word](c.Name) + SizeString[Word](c.Name) +
Size(SizeLong) + Size(SizeLong) +
c.Props.Size() c.Properties.Size()
} }
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
@ -124,9 +124,9 @@ func (c *CoreInfo) UnmarshalBinary(data []byte) error { return Unmarshal(data, c
// The CoreDone event is emitted as a result of a client Sync method. // The CoreDone event is emitted as a result of a client Sync method.
type CoreDone struct { type CoreDone struct {
// Passed from [CoreSync.ID]. // Passed from [CoreSync.ID].
ID Int ID Int `json:"id"`
// Passed from [CoreSync.Sequence]. // Passed from [CoreSync.Sequence].
Sequence Int Sequence Int `json:"sequence"`
} }
// Size satisfies [KnownSize] with a constant value. // Size satisfies [KnownSize] with a constant value.
@ -142,11 +142,11 @@ func (c *CoreDone) UnmarshalBinary(data []byte) error { return Unmarshal(data, c
// It is emitted before the global becomes visible in the registry. // It is emitted before the global becomes visible in the registry.
type CoreBoundProps struct { type CoreBoundProps struct {
// A proxy id. // A proxy id.
ID Int ID Int `json:"id"`
// The global_id as it will appear in the registry. // The global_id as it will appear in the registry.
GlobalID Int GlobalID Int `json:"global_id"`
// The properties of the global. // The properties of the global.
Props *SPADict Properties *SPADict `json:"props"`
} }
// Size satisfies [KnownSize] with a value computed at runtime. // Size satisfies [KnownSize] with a value computed at runtime.
@ -154,7 +154,7 @@ func (c *CoreBoundProps) Size() Word {
return SizePrefix + return SizePrefix +
Size(SizeInt) + Size(SizeInt) +
Size(SizeInt) + Size(SizeInt) +
c.Props.Size() c.Properties.Size()
} }
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
@ -166,7 +166,7 @@ func (c *CoreBoundProps) UnmarshalBinary(data []byte) error { return Unmarshal(d
// CoreHello is the first message sent by a client. // CoreHello is the first message sent by a client.
type CoreHello struct { type CoreHello struct {
// The version number of the client, usually PW_VERSION_CORE. // The version number of the client, usually PW_VERSION_CORE.
Version Int Version Int `json:"version"`
} }
// Size satisfies [KnownSize] with a constant value. // Size satisfies [KnownSize] with a constant value.
@ -188,9 +188,9 @@ const (
// operations before the Sync method have been completed. // operations before the Sync method have been completed.
type CoreSync struct { type CoreSync struct {
// The id will be returned in the Done event. // The id will be returned in the Done event.
ID Int ID Int `json:"id"`
// Usually generated automatically and will be returned in the Done event. // Usually generated automatically and will be returned in the Done event.
Sequence Int Sequence Int `json:"sequence"`
} }
// Size satisfies [KnownSize] with a constant value. // Size satisfies [KnownSize] with a constant value.
@ -211,10 +211,10 @@ func (c *CoreSync) UnmarshalBinary(data []byte) error { return Unmarshal(data, c
type CoreGetRegistry struct { type CoreGetRegistry struct {
// The version of the registry interface used on the client, // The version of the registry interface used on the client,
// usually PW_VERSION_REGISTRY. // usually PW_VERSION_REGISTRY.
Version Int Version Int `json:"version"`
// The id of the new proxy with the registry interface, // The id of the new proxy with the registry interface,
// ends up as [Header.ID] in future messages. // ends up as [Header.ID] in future messages.
NewID Int NewID Int `json:"new_id"`
} }
// Size satisfies [KnownSize] with a constant value. // Size satisfies [KnownSize] with a constant value.

View File

@ -34,7 +34,7 @@ func TestCoreInfo(t *testing.T) {
Version: "1.4.7", Version: "1.4.7",
Name: "pipewire-0", Name: "pipewire-0",
ChangeMask: pipewire.PW_CORE_CHANGE_MASK_PROPS, ChangeMask: pipewire.PW_CORE_CHANGE_MASK_PROPS,
Props: &pipewire.SPADict{ Properties: &pipewire.SPADict{
{Key: "config.name", Value: "pipewire.conf"}, {Key: "config.name", Value: "pipewire.conf"},
{Key: "application.name", Value: "pipewire"}, {Key: "application.name", Value: "pipewire"},
{Key: "application.process.binary", Value: "pipewire"}, {Key: "application.process.binary", Value: "pipewire"},
@ -88,7 +88,7 @@ func TestCoreBoundProps(t *testing.T) {
{"sample", samplePWContainer[1][1][1], pipewire.CoreBoundProps{ {"sample", samplePWContainer[1][1][1], pipewire.CoreBoundProps{
ID: pipewire.PW_ID_CLIENT, ID: pipewire.PW_ID_CLIENT,
GlobalID: 34, GlobalID: 34,
Props: &pipewire.SPADict{ Properties: &pipewire.SPADict{
{Key: "object.serial", Value: "34"}, {Key: "object.serial", Value: "34"},
{Key: "module.id", Value: "2"}, {Key: "module.id", Value: "2"},
{Key: "pipewire.protocol", Value: "protocol-native"}, {Key: "pipewire.protocol", Value: "protocol-native"},

View File

@ -445,9 +445,9 @@ func unmarshalCheckTypeBounds(data *[]byte, t Word, sizeP *Word) error {
// the destination object defined by the Id field. // the destination object defined by the Id field.
type Footer[T any] struct { type Footer[T any] struct {
// The footer opcode. // The footer opcode.
Opcode Id Opcode Id `json:"opcode"`
// The footer payload struct. // The footer payload struct.
Payload T Payload T `json:"payload"`
} }
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].