diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-11-27 02:15:44 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-11-27 02:17:38 +0900 |
| commit | 73987be7d4c850f8b95babb8f68e6ccb6cafcee4 (patch) | |
| tree | c46e77b552fe508b7970be199699b07ae86cb288 /internal/pipewire/client.go | |
| parent | 563b5e66fc0dfe0abc4a4b8c96f0f89ef71c3422 (diff) | |
internal/pipewire: size without serialisation
This is required to achieve zero allocation (other than reflect).
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/pipewire/client.go')
| -rw-r--r-- | internal/pipewire/client.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/internal/pipewire/client.go b/internal/pipewire/client.go index 0dce269b..0847ac0a 100644 --- a/internal/pipewire/client.go +++ b/internal/pipewire/client.go @@ -46,6 +46,14 @@ type ClientInfo struct { Props *SPADict } +// Size satisfies [KnownSize] with a value computed at runtime. +func (c *ClientInfo) Size() Word { + return SizePrefix + + Size(SizeInt) + + Size(SizeLong) + + c.Props.Size() +} + // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. func (c *ClientInfo) MarshalBinary() ([]byte, error) { return Marshal(c) } @@ -58,6 +66,9 @@ type ClientUpdateProperties struct { Props *SPADict } +// Size satisfies [KnownSize] with a value computed at runtime. +func (c *ClientUpdateProperties) Size() Word { return SizePrefix + c.Props.Size() } + // MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal]. func (c *ClientUpdateProperties) MarshalBinary() ([]byte, error) { return Marshal(c) } |
