You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
2.1 KiB

6 years ago
  1. // Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
  2. //
  3. // You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  4. // copy, modify, and distribute this software in source code or binary form for use
  5. // in connection with the web services and APIs provided by Facebook.
  6. //
  7. // As with any software that integrates with the Facebook platform, your use of
  8. // this software is subject to the Facebook Developer Principles and Policies
  9. // [http://developers.facebook.com/policy/]. This copyright notice shall be
  10. // included in all copies or substantial portions of the software.
  11. //
  12. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  14. // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  15. // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  16. // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  17. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  18. /**
  19. The common interface for components that initiate sharing.
  20. */
  21. public protocol ContentSharingProtocol {
  22. associatedtype Content: ContentProtocol
  23. /// The content that is being shared.
  24. var content: Content { get }
  25. /// The completion handler to call when sharing is complete.
  26. var completion: ((ContentSharerResult<Content>) -> Void)? { get set }
  27. /**
  28. A Boolean value that indicates whether the receiver should fail if it finds an error with the share content.
  29. If `false`, the sharer will still be displayed without the data that was mis-configured.
  30. For example, an invalid `placeId` specified on the `content` would produce a data error.
  31. */
  32. var failsOnInvalidData: Bool { get }
  33. /**
  34. Validates the content on the receiver.
  35. */
  36. func validate() throws
  37. }
  38. /**
  39. The results of an attempted operation by a `ContentSharer`.
  40. */
  41. public enum ContentSharerResult<Content: ContentProtocol> {
  42. /// The operation was successful.
  43. case success(Content.Result)
  44. /// The operation failed.
  45. case failed(Error)
  46. /// The operation was cancelled by the user.
  47. case cancelled
  48. }