Skip to content

Commit 7b9b049

Browse files
authored
Expose dsd.Dump without Identifier (#3)
1 parent bc6ff03 commit 7b9b049

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

dsd/dsd.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ func Dump(t interface{}, format uint8) ([]byte, error) {
9393

9494
// DumpIndent stores the interface as a dsd formatted data structure with indentation, if available.
9595
func DumpIndent(t interface{}, format uint8, indent string) ([]byte, error) {
96-
data, err := dumpWithoutIdentifier(t, format, indent)
96+
data, err := DumpWithoutIdentifier(t, format, indent)
9797
if err != nil {
9898
return nil, err
9999
}
@@ -102,7 +102,8 @@ func DumpIndent(t interface{}, format uint8, indent string) ([]byte, error) {
102102
return append(varint.Pack8(format), data...), nil
103103
}
104104

105-
func dumpWithoutIdentifier(t interface{}, format uint8, indent string) ([]byte, error) {
105+
// DumpWithoutIdentifier stores the interface as a data structure, without format identifier, but with indentation, if specified and available.
106+
func DumpWithoutIdentifier(t interface{}, format uint8, indent string) ([]byte, error) {
106107
format, ok := ValidateSerializationFormat(format)
107108
if !ok {
108109
return nil, ErrIncompatibleFormat

dsd/http.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func DumpToHTTPRequest(r *http.Request, t interface{}, format uint8) error {
6565
}
6666

6767
// Serialize data.
68-
data, err := dumpWithoutIdentifier(t, format, "")
68+
data, err := DumpWithoutIdentifier(t, format, "")
6969
if err != nil {
7070
return fmt.Errorf("dsd: failed to serialize: %w", err)
7171
}
@@ -117,7 +117,7 @@ func MimeDump(t any, accept string) (data []byte, mimeType string, format uint8,
117117
}
118118

119119
// Serialize and return.
120-
data, err = dumpWithoutIdentifier(t, format, "")
120+
data, err = DumpWithoutIdentifier(t, format, "")
121121
return data, mimeType, format, err
122122
}
123123

0 commit comments

Comments
 (0)