application_data.go 892 B

1234567891011121314151617181920212223242526272829
  1. // SPDX-FileCopyrightText: 2023 The Pion community <https://pion.ly>
  2. // SPDX-License-Identifier: MIT
  3. package protocol
  4. // ApplicationData messages are carried by the record layer and are
  5. // fragmented, compressed, and encrypted based on the current connection
  6. // state. The messages are treated as transparent data to the record
  7. // layer.
  8. // https://tools.ietf.org/html/rfc5246#section-10
  9. type ApplicationData struct {
  10. Data []byte
  11. }
  12. // ContentType returns the ContentType of this content
  13. func (a ApplicationData) ContentType() ContentType {
  14. return ContentTypeApplicationData
  15. }
  16. // Marshal encodes the ApplicationData to binary
  17. func (a *ApplicationData) Marshal() ([]byte, error) {
  18. return append([]byte{}, a.Data...), nil
  19. }
  20. // Unmarshal populates the ApplicationData from binary
  21. func (a *ApplicationData) Unmarshal(data []byte) error {
  22. a.Data = append([]byte{}, data...)
  23. return nil
  24. }