decoder.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package decoder
  2. import (
  3. "io"
  4. "io/fs"
  5. "github.com/langgenius/dify-plugin-daemon/internal/types/entities/plugin_entities"
  6. )
  7. // PluginDecoder is an interface for decoding and interacting with plugin files
  8. type PluginDecoder interface {
  9. // Open initializes the decoder and prepares it for use
  10. Open() error
  11. // Walk traverses the plugin files and calls the provided function for each file
  12. // The function is called with the filename and directory of each file
  13. Walk(fn func(filename string, dir string) error) error
  14. // ReadFile reads the entire contents of a file and returns it as a byte slice
  15. ReadFile(filename string) ([]byte, error)
  16. // Close releases any resources used by the decoder
  17. Close() error
  18. // Stat returns file info for the specified filename
  19. Stat(filename string) (fs.FileInfo, error)
  20. // FileReader returns an io.ReadCloser for reading the contents of a file
  21. // Remember to close the reader when done using it
  22. FileReader(filename string) (io.ReadCloser, error)
  23. // Signature returns the signature of the plugin, if available
  24. Signature() (string, error)
  25. // CreateTime returns the creation time of the plugin as a Unix timestamp
  26. CreateTime() (int64, error)
  27. // Manifest returns the manifest of the plugin
  28. Manifest() (plugin_entities.PluginDeclaration, error)
  29. }