[−][src]Struct fbinit::FacebookInit
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]
pub fn arbitrary<G: Gen>(_: &mut G) -> Self
[src]
pub fn shrink(&self) -> Box<dyn Iterator<Item = Self> + 'static, Global>
[src]
impl Clone for FacebookInit
[src]
pub fn clone(&self) -> FacebookInit
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for FacebookInit
[src]
impl Debug for FacebookInit
[src]
Auto Trait Implementations
impl RefUnwindSafe for FacebookInit
[src]
impl Send for FacebookInit
[src]
impl Sync for FacebookInit
[src]
impl Unpin for FacebookInit
[src]
impl UnwindSafe for FacebookInit
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,