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 can be passed to crate::ConfigBuilder::data_source to drive the FDv1 data
source, or to crate::DataSystemBuilder::synchronizer to drive the FDv2 data system. When
the SDK client is started, it receives the current flag state from TestData and is notified
of subsequent changes.
With the FDv2 data system, updates are delivered asynchronously. A change made with
TestData::update may take a moment to be reflected in flag evaluations.
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§
Source§impl FDv2SynchronizerConfig for TestData
impl FDv2SynchronizerConfig for TestData
Source§fn build_synchronizer(
&self,
_context: &DataSourceBuildContext<'_>,
) -> Result<Box<dyn SynchronizerFactory>, DataSystemBuildError>
fn build_synchronizer( &self, _context: &DataSourceBuildContext<'_>, ) -> Result<Box<dyn SynchronizerFactory>, DataSystemBuildError>
Source§fn to_owned(&self) -> Box<dyn FDv2SynchronizerConfig>
fn to_owned(&self) -> Box<dyn FDv2SynchronizerConfig>
Auto Trait Implementations§
impl !RefUnwindSafe for TestData
impl !UnwindSafe for TestData
impl Freeze for TestData
impl Send for TestData
impl Sync for TestData
impl Unpin for TestData
impl UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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