From 7b9b0494da5cc81ea6f3ebf9f2bff0b0545f3b2d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20H=C3=A5=C3=A5vi?= <dhaavi@users.noreply.github.com>
Date: Fri, 21 Feb 2025 10:53:32 +0100
Subject: [PATCH] Expose dsd.Dump without Identifier (#3)

---
 dsd/dsd.go  | 5 +++--
 dsd/http.go | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/dsd/dsd.go b/dsd/dsd.go
index f04a7c9..ae6e276 100644
--- a/dsd/dsd.go
+++ b/dsd/dsd.go
@@ -93,7 +93,7 @@ func Dump(t interface{}, format uint8) ([]byte, error) {
 
 // DumpIndent stores the interface as a dsd formatted data structure with indentation, if available.
 func DumpIndent(t interface{}, format uint8, indent string) ([]byte, error) {
-	data, err := dumpWithoutIdentifier(t, format, indent)
+	data, err := DumpWithoutIdentifier(t, format, indent)
 	if err != nil {
 		return nil, err
 	}
@@ -102,7 +102,8 @@ func DumpIndent(t interface{}, format uint8, indent string) ([]byte, error) {
 	return append(varint.Pack8(format), data...), nil
 }
 
-func dumpWithoutIdentifier(t interface{}, format uint8, indent string) ([]byte, error) {
+// DumpWithoutIdentifier stores the interface as a data structure, without format identifier, but with indentation, if specified and available.
+func DumpWithoutIdentifier(t interface{}, format uint8, indent string) ([]byte, error) {
 	format, ok := ValidateSerializationFormat(format)
 	if !ok {
 		return nil, ErrIncompatibleFormat
diff --git a/dsd/http.go b/dsd/http.go
index 85aab16..de05862 100644
--- a/dsd/http.go
+++ b/dsd/http.go
@@ -65,7 +65,7 @@ func DumpToHTTPRequest(r *http.Request, t interface{}, format uint8) error {
 	}
 
 	// Serialize data.
-	data, err := dumpWithoutIdentifier(t, format, "")
+	data, err := DumpWithoutIdentifier(t, format, "")
 	if err != nil {
 		return fmt.Errorf("dsd: failed to serialize: %w", err)
 	}
@@ -117,7 +117,7 @@ func MimeDump(t any, accept string) (data []byte, mimeType string, format uint8,
 	}
 
 	// Serialize and return.
-	data, err = dumpWithoutIdentifier(t, format, "")
+	data, err = DumpWithoutIdentifier(t, format, "")
 	return data, mimeType, format, err
 }