github.com/pion/dtls/v2@v2.2.12/pkg/protocol/application_data.go (about)

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