pub struct PortableExtensions(/* private fields */);Expand description
A bag of preserved (key, value) pairs, in the document’s own vocabulary.
Used for both channels (see the module docs): the nested extensions object this
build writes, and the flattened catch-all it only reads. A newtype over a JSON value
map, rather than a bare Map, so the one inserter is private and every write goes
through PortableTimeDocument::insert_extension. A JSON map (not a YAML map)
because this document is JSON and a YAML value JSON cannot carry is withheld and
diagnosed rather than silently reshaped. The map is sorted (serde_json’s
preserve_order feature is off), so key order is normalised while the values — the
thing a round trip preserves — are kept exactly.
§No public route to a key that could shadow a projected field
Deserialize is derived (a document has to be readable), so a caller can obtain a
bag naming any key. What a caller cannot do is hand one to a flattened channel: those
fields are private everywhere they exist, and the only public way in is the checked
nesting shown below, where the key lands inside an object of its own and can therefore
never duplicate — or be read in place of — the value beside it. That is a compile-time
property, so it is asserted as one:
use tix::time_tracking::portable::{PortableExtensions, PortableTimeDocument};
let mut document: PortableTimeDocument = unimplemented!();
// The catch-all is private: there is no public field to drop a shadowing key into.
document.unknown = PortableExtensions::default();The nested channel, for contrast, is checked rather than forbidden:
use tix::time_tracking::portable::{PortableTimeDocument, FORMAT};
use serde_json::json;
let mut document: PortableTimeDocument = unimplemented!();
document.insert_extension("format", json!("metadata, not a marker"));
let _ = FORMAT;Implementations§
Trait Implementations§
Source§impl Clone for PortableExtensions
impl Clone for PortableExtensions
Source§impl Debug for PortableExtensions
impl Debug for PortableExtensions
Source§impl Default for PortableExtensions
impl Default for PortableExtensions
Source§impl<'de> Deserialize<'de> for PortableExtensions
impl<'de> Deserialize<'de> for PortableExtensions
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for PortableExtensions
impl PartialEq for PortableExtensions
Source§impl Serialize for PortableExtensions
impl Serialize for PortableExtensions
impl StructuralPartialEq for PortableExtensions
Auto Trait Implementations§
impl Freeze for PortableExtensions
impl RefUnwindSafe for PortableExtensions
impl Send for PortableExtensions
impl Sync for PortableExtensions
impl Unpin for PortableExtensions
impl UnsafeUnpin for PortableExtensions
impl UnwindSafe for PortableExtensions
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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