pub struct LazyContext(/* private fields */);
Expand description
A context that is initialized lazily upon first use.
This is intended to be used with LazyChannel
to create static channels
attached to static contexts.
Refer to the Context
documentation for more information about contexts.
§Example
use foxglove::schemas::Log;
use foxglove::{LazyChannel, LazyContext, LazyRawChannel};
// Create two channels for the same topic, in different contexts.
static TOPIC: &str = "/topic";
static CTX_A: LazyContext = LazyContext::new();
static CTX_B: LazyContext = LazyContext::new();
static LOG_A: LazyChannel<Log> = CTX_A.channel(TOPIC);
static LOG_B: LazyRawChannel = CTX_B.raw_channel(TOPIC, "json");
LOG_A.log(&Log {
message: "hello a".into(),
..Log::default()
});
LOG_B.log(br#"{"message": "hello b"}"#);
Implementations§
Source§impl LazyContext
impl LazyContext
Sourcepub const fn get_default() -> &'static Self
pub const fn get_default() -> &'static Self
Returns a reference to the lazily-initialized default context.
Sourcepub const fn channel<T: Encode>(
&'static self,
topic: &'static str,
) -> LazyChannel<T>
pub const fn channel<T: Encode>( &'static self, topic: &'static str, ) -> LazyChannel<T>
Creates a new lazily-initialized channel in this context.
Sourcepub const fn raw_channel(
&'static self,
topic: &'static str,
message_encoding: &'static str,
) -> LazyRawChannel
pub const fn raw_channel( &'static self, topic: &'static str, message_encoding: &'static str, ) -> LazyRawChannel
Creates a new lazily-initialized raw channel in this context.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for LazyContext
impl !RefUnwindSafe for LazyContext
impl Send for LazyContext
impl Sync for LazyContext
impl Unpin for LazyContext
impl !UnwindSafe for LazyContext
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U> SaturatingInto<T> for Uwhere
T: SaturatingFrom<U>,
impl<T, U> SaturatingInto<T> for Uwhere
T: SaturatingFrom<U>,
Source§fn saturating_into(self) -> T
fn saturating_into(self) -> T
Performs the conversion.