network_state.rs 711 B

1234567891011121314151617181920212223242526272829303132
  1. use flowy_derive::{ProtoBuf, ProtoBuf_Enum};
  2. #[derive(ProtoBuf_Enum, Debug, Clone, Eq, PartialEq)]
  3. pub enum NetworkType {
  4. UnknownNetworkType = 0,
  5. Wifi = 1,
  6. Cell = 2,
  7. Ethernet = 3,
  8. }
  9. impl NetworkType {
  10. pub fn is_connect(&self) -> bool {
  11. match self {
  12. NetworkType::UnknownNetworkType => false,
  13. NetworkType::Wifi => true,
  14. NetworkType::Cell => true,
  15. NetworkType::Ethernet => true,
  16. }
  17. }
  18. }
  19. impl std::default::Default for NetworkType {
  20. fn default() -> Self {
  21. NetworkType::UnknownNetworkType
  22. }
  23. }
  24. #[derive(ProtoBuf, Debug, Default, Clone)]
  25. pub struct NetworkState {
  26. #[pb(index = 1)]
  27. pub ty: NetworkType,
  28. }