aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/pipewire/core.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/pipewire/core.go')
-rw-r--r--internal/pipewire/core.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/pipewire/core.go b/internal/pipewire/core.go
index 407ea954..1ef2f790 100644
--- a/internal/pipewire/core.go
+++ b/internal/pipewire/core.go
@@ -102,6 +102,19 @@ type CoreInfo struct {
Props *SPADict
}
+// Size satisfies [KnownSize] with a value computed at runtime.
+func (c *CoreInfo) Size() Word {
+ return SizePrefix +
+ Size(SizeInt) +
+ Size(SizeInt) +
+ SizeString[Word](c.UserName) +
+ SizeString[Word](c.HostName) +
+ SizeString[Word](c.Version) +
+ SizeString[Word](c.Name) +
+ Size(SizeLong) +
+ c.Props.Size()
+}
+
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
func (c *CoreInfo) MarshalBinary() ([]byte, error) { return Marshal(c) }
@@ -116,6 +129,9 @@ type CoreDone struct {
Sequence Int
}
+// Size satisfies [KnownSize] with a constant value.
+func (c *CoreDone) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
+
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
func (c *CoreDone) MarshalBinary() ([]byte, error) { return Marshal(c) }
@@ -133,6 +149,14 @@ type CoreBoundProps struct {
Props *SPADict
}
+// Size satisfies [KnownSize] with a value computed at runtime.
+func (c *CoreBoundProps) Size() Word {
+ return SizePrefix +
+ Size(SizeInt) +
+ Size(SizeInt) +
+ c.Props.Size()
+}
+
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [Marshal].
func (c *CoreBoundProps) MarshalBinary() ([]byte, error) { return Marshal(c) }
@@ -145,6 +169,9 @@ type CoreHello struct {
Version Int
}
+// Size satisfies [KnownSize] with a constant value.
+func (c *CoreHello) Size() Word { return SizePrefix + Size(SizeInt) }
+
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [MarshalAppend].
func (c *CoreHello) MarshalBinary() ([]byte, error) {
return MarshalAppend(make([]byte, 0, 24), c)
@@ -168,6 +195,9 @@ type CoreSync struct {
Sequence Int
}
+// Size satisfies [KnownSize] with a constant value.
+func (c *CoreSync) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
+
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [MarshalAppend].
func (c *CoreSync) MarshalBinary() ([]byte, error) {
return MarshalAppend(make([]byte, 0, 40), c)
@@ -191,6 +221,9 @@ type CoreGetRegistry struct {
NewID Int
}
+// Size satisfies [KnownSize] with a constant value.
+func (c *CoreGetRegistry) Size() Word { return SizePrefix + Size(SizeInt) + Size(SizeInt) }
+
// MarshalBinary satisfies [encoding.BinaryMarshaler] via [MarshalAppend].
func (c *CoreGetRegistry) MarshalBinary() ([]byte, error) {
return MarshalAppend(make([]byte, 0, 40), c)