pub struct TestData { /* private fields */ }Expand description
A mechanism for providing dynamically updatable feature flag state in a simplified form to an SDK client.
TestData implements DataSourceFactory, so it can be passed to
crate::ConfigBuilder::data_source. When the SDK client is started, it will receive the
current flag state from TestData and will be notified of any subsequent changes.
Flag data can be provided using FlagBuilder (via TestData::update)
or by passing fully constructed Flag objects (via TestData::use_preconfigured_flag).
Cloning a TestData creates a new handle that shares the same underlying state.
Implementations§
Source§impl TestData
impl TestData
Sourcepub fn flag(&self, key: &str) -> FlagBuilder
pub fn flag(&self, key: &str) -> FlagBuilder
Returns a copy of the current FlagBuilder for the specified flag key, or a new default
builder if the flag has not been configured yet.
If the flag was previously set via TestData::use_preconfigured_flag, this returns a new
default builder since FlagBuilder cannot represent all flag fields
(e.g. prerequisites, migration settings, client visibility) and hydrating from a Flag
would silently lose that data.
Sourcepub fn update(&self, builder: FlagBuilder)
pub fn update(&self, builder: FlagBuilder)
Updates the test data with the given flag builder.
If there are any connected SDK clients, they will be notified of the flag change. The flag version is automatically incremented.
Sourcepub fn use_preconfigured_flag(&self, flag: Flag)
pub fn use_preconfigured_flag(&self, flag: Flag)
Sets a preconfigured Flag directly.
Use this when you need to set a flag with a configuration that cannot be expressed through
FlagBuilder. The flag version is automatically managed.
Note: calling TestData::flag after this will return a new default builder, not a
builder derived from the preconfigured flag.
Sourcepub fn use_preconfigured_segment(&self, segment: Segment)
pub fn use_preconfigured_segment(&self, segment: Segment)
Sets a preconfigured Segment directly.
The segment version is automatically managed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TestData
impl !RefUnwindSafe for TestData
impl Send for TestData
impl Sync for TestData
impl Unpin for TestData
impl UnsafeUnpin for TestData
impl !UnwindSafe for TestData
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more