github.com/anchore/syft@v1.4.2-0.20240516191711-1bec1fc5d397/syft/sbom/format.go (about) 1 package sbom 2 3 import ( 4 "io" 5 ) 6 7 type FormatID string 8 9 // String returns a string representation of the FormatID. 10 func (f FormatID) String() string { 11 return string(f) 12 } 13 14 const AnyVersion = "" 15 16 type FormatEncoder interface { 17 ID() FormatID 18 Aliases() []string 19 Version() string 20 Encode(io.Writer, SBOM) error 21 } 22 23 type FormatDecoder interface { 24 // Decode will return an SBOM from the given reader. If the bytes are not a valid SBOM for the given format 25 // then an error will be returned. 26 Decode(io.Reader) (*SBOM, FormatID, string, error) 27 28 // Identify will return the format ID and version for the given reader. Note: this does not validate the 29 // full SBOM, only pulls the minimal information necessary to identify the format. 30 Identify(io.Reader) (FormatID, string) 31 }