Repository navigation
refactor(core): restore ValueOwned serde constructors and keep ValueSerde lazy-only - #334
Merged
Merged
Conversation
…ry_serialize `ValueSerde::try_into_owned(self)` bypassed any cached snapshot on the adapter instance, allowing `into_owned()` and `try_into_owned()` on an already-inspected adapter to observe different values under interior mutability while requiring callers who only want fallible serialization to construct a throwaway `ValueSerde`. Replace `ValueSerde::try_into_owned(self)` with the associated function `ValueSerde::try_serialize(value: &'a T) -> Result<ValueOwned, Error>` so each `ValueSerde` instance strictly represents a single memoized lazy snapshot. Signed-off-by: tison <wander4096@gmail.com>
…erde lazy-only Restore `ValueOwned::from_serde` and `ValueOwned::try_from_serde` for eager owned conversion, and narrow `kv::ValueSerde` to a pure lazy-initialization field wrapper (`new`, `Deref<Target = ValueOwned>`, `LogValue`, and `Debug`) without eager conversion methods. Signed-off-by: tison <wander4096@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ValueOwned::from_serdeandValueOwned::try_from_serde(behind theserdefeature) inlogforth-corefor eager owned conversion ofserde::Serializevalues.kv::ValueSerdeto a pure lazy-initialization field wrapper (ValueSerde::new,Deref<Target = ValueOwned>,LogValue, andDebug), removinginto_owned,try_into_owned, andFrom<ValueSerde<'_, T>>forValueOwned.ValueOwned::from_serdedirectly inlogforth-bridge-loginstead of allocating a temporaryOnceLockviaValueSerde, and update workspace docs, integration tests, andCHANGELOG.md.Design Notes
ValueOwned::{from_serde, try_from_serde}) from lazy field capture (ValueSerde::new) eliminates duplicateValueOwnedconstructors, avoids constructing an unusedOnceLockon eager paths, prevents accidental eager serialization throughInto<ValueOwned>, and guarantees that everyValueSerdeinstance represents a single lazy snapshot.Test Plan
cargo x checkcargo x testcargo x lint