[][src]Struct fbinit::FacebookInit

pub struct FacebookInit { /* fields omitted */ }

This type is a token that allows code to prove initFacebook has been called. A function can require this proof by taking _fb: FacebookInit as an argument.

The basic assumption of initFacebook is that it happens at the very beginning of main before there are additional threads. It must be allowed to modify process-global state like env vars or gflags without the risk of undefined behavior from other code concurrently reading those things.

The only way to obtain a proof token is through a pair of attribute macros exported by this crate. #\[fbinit::main\] is placed on your main function and will call initFacebook and provide the resulting proof:

#[fbinit::main]
fn main(fb: fbinit::FacebookInit) {
    /* ... */
}

The proof argument is optional. If you don't need it, this is fine too:

#[fbinit::main]
fn main() {
    /* ... */
}

If main is async, the attribute behaves like `#[tokio::main].

#[fbinit::main]
async fn main(fb: fbinit::FacebookInit) {
    yay().await;
}

async fn yay() {}

There is also #\[fbinit::test\] which behaves like #\[test\] or #\[tokio::test\].

#[fbinit::test]
fn test_my_service(fb: fbinit::FacebookInit) {
    /* ... */
}

#[fbinit::test]
async fn async_test(fb: fbinit::FacebookInit) {
    /* ... */
}

Trait Implementations

impl Arbitrary for FacebookInit[src]

impl Clone for FacebookInit[src]

impl Copy for FacebookInit[src]

impl Debug for FacebookInit[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,