uri.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package fyne
  2. import (
  3. "fmt"
  4. "io"
  5. )
  6. // URIReadCloser represents a cross platform data stream from a file or provider of data.
  7. // It may refer to an item on a filesystem or data in another application that we have access to.
  8. type URIReadCloser interface {
  9. io.ReadCloser
  10. URI() URI
  11. }
  12. // URIWriteCloser represents a cross platform data writer for a file resource.
  13. // This will normally refer to a local file resource.
  14. type URIWriteCloser interface {
  15. io.WriteCloser
  16. URI() URI
  17. }
  18. // URI represents the identifier of a resource on a target system. This
  19. // resource may be a file or another data source such as an app or file sharing
  20. // system.
  21. //
  22. // In general, it is expected that URI implementations follow IETF RFC3896.
  23. // Implementations are highly recommended to utilize net/url to implement URI
  24. // parsing methods, especially Scheme(), AUthority(), Path(), Query(), and
  25. // Fragment().
  26. type URI interface {
  27. fmt.Stringer
  28. // Extension should return the file extension of the resource
  29. // (including the dot) referenced by the URI. For example, the
  30. // Extension() of 'file://foo/bar.baz' is '.baz'. May return an
  31. // empty string if the referenced resource has none.
  32. Extension() string
  33. // Name should return the base name of the item referenced by the URI.
  34. // For example, the Name() of 'file://foo/bar.baz' is 'bar.baz'.
  35. Name() string
  36. // MimeType should return the content type of the resource referenced
  37. // by the URI. The returned string should be in the format described
  38. // by Section 5 of RFC2045 ("Content-Type Header Field").
  39. MimeType() string
  40. // Scheme should return the URI scheme of the URI as defined by IETF
  41. // RFC3986. For example, the Scheme() of 'file://foo/bar.baz` is
  42. // 'file'.
  43. //
  44. // Scheme should always return the scheme in all lower-case characters.
  45. Scheme() string
  46. // Authority should return the URI authority, as defined by IETF
  47. // RFC3986.
  48. //
  49. // NOTE: the RFC3986 can be obtained by combining the User and Host
  50. // Fields of net/url's URL structure. Consult IETF RFC3986, section
  51. // 3.2, pp. 17.
  52. //
  53. // Since: 2.0
  54. Authority() string
  55. // Path should return the URI path, as defined by IETF RFC3986.
  56. //
  57. // Since: 2.0
  58. Path() string
  59. // Query should return the URI query, as defined by IETF RFC3986.
  60. //
  61. // Since: 2.0
  62. Query() string
  63. // Fragment should return the URI fragment, as defined by IETF
  64. // RFC3986.
  65. //
  66. // Since: 2.0
  67. Fragment() string
  68. }
  69. // ListableURI represents a URI that can have child items, most commonly a
  70. // directory on disk in the native filesystem.
  71. //
  72. // Since: 1.4
  73. type ListableURI interface {
  74. URI
  75. // List returns a list of child URIs of this URI.
  76. List() ([]URI, error)
  77. }