1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! # GNOME Online Accounts
//!
//! [![Documentation](https://docs.rs/goa/badge.svg)](https://docs.rs/goa)
//!
//! The Rust bindings for libgoa generated by GIR.
//!
//! A simpler API is planed.
//!
//! ## Usage
//!
//! ### Install libgoa
//!
//! - Fedora
//!
//!   ```none
//!   # dnf install gnome-online-accounts-devel
//!   ```
//!
//! - Debian and derived
//!
//!   ```none
//!   # apt install libgoa-1.0-dev
//!   ```
//!
//! ### Add the dependency
//!
//! ```toml
//! [dependencies]
//! goa = "0.0.3"
//! ```
//!
//! ## Generate and build from scratch
//!
//! Install [GIR](https://github.com/gtk-rs/gir).
//!
//! ```none
//! git clone --recurse https://gitlab.gnome.org/World/Rust/libgoa-rs
//! cd libgoa-rs/goa-sys && gir # Generates the goa-sys crate
//! cd .. && gir # Generates the goa crate
//! cargo build
//! ```
//!
//! ## License
//!
//! Either MIT or Apache 2.0, left to the user's choice.

#[macro_use]
extern crate glib;
extern crate fragile;
extern crate gio;
extern crate gio_sys;
extern crate glib_sys;
extern crate goa_sys;
extern crate gobject_sys;

#[rustfmt::skip]
mod auto;

pub use auto::*;
use std as futures;

//FIXME: I must implement it by hand. Why?
#[doc(hidden)]
impl glib::translate::FromGlibPtrFull<*mut glib_sys::GError> for Error {
    #[inline]
    unsafe fn from_glib_full(ptr: *mut glib_sys::GError) -> Self {
        match (*ptr).code {
            goa_sys::GOA_ERROR_FAILED => Error::Failed,
            goa_sys::GOA_ERROR_NOT_SUPPORTED => Error::NotSupported,
            goa_sys::GOA_ERROR_DIALOG_DISMISSED => Error::DialogDismissed,
            goa_sys::GOA_ERROR_ACCOUNT_EXISTS => Error::AccountExists,
            goa_sys::GOA_ERROR_NOT_AUTHORIZED => Error::NotAuthorized,
            goa_sys::GOA_ERROR_SSL => Error::Ssl,
            value => Error::__Unknown(value),
        }
    }
}