network_state.rs 749 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. Bluetooth = 4,
  9. VPN = 5,
  10. }
  11. impl NetworkType {
  12. pub fn is_connect(&self) -> bool {
  13. match self {
  14. NetworkType::UnknownNetworkType | NetworkType::Bluetooth => false,
  15. NetworkType::Wifi | NetworkType::Cell | NetworkType::Ethernet | NetworkType::VPN => 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. }