-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.go
More file actions
42 lines (37 loc) · 1.09 KB
/
types.go
File metadata and controls
42 lines (37 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package mediaorient
import (
"fmt"
"image"
)
// Result is a generic struct that represents the result of an operation.
//
// Parameters:
// - Data is data of type T.
// - Err is an error that indicates if the operation failed.
type Result[T any] struct {
Data T
Err error
}
// IsSuccess returns true if the operation was successful (no error occurred), false otherwise.
func (r *Result[T]) IsSuccess() bool {
return r.Err == nil
}
// Media represents a media object.
type Media struct {
// Name of the media.
Name string `json:"name"`
// Type of the media (e.g., image, video).
Type string `json:"type"`
// Rotation represents the rotation of the media.
Rotation int `json:"rotation"`
// Frames contain the image data of the media.
Frames []image.Image `json:"-"`
// Width represents the width of the media in pixels.
Width int `json:"width"`
// Height represents the height of the media in pixels.
Height int `json:"height"`
}
func (m *Media) String() string {
return fmt.Sprintf(`{Name: %s, Type: %s, Rotation: %d, Width: %d, Height: %d}`,
m.Name, m.Type, m.Rotation, m.Width, m.Height)
}