MCPcopy Create free account
hub / github.com/bitflags/bitflags / serialize

Function serialize

src/external/serde.rs:18–30  ·  view source on GitHub ↗

Serialize a set of flags as a human-readable string or their underlying bits. Any unknown bits will be retained. */

(flags: &B, serializer: S)

Source from the content-addressed store, hash-verified

16Any unknown bits will be retained.
17*/
18pub fn serialize<B: Flags, S: Serializer>(flags: &B, serializer: S) -> Result<S::Ok, S::Error>
19where
20 B::Bits: WriteHex + Serialize,
21{
22 // Serialize human-readable flags as a string like `"A | B"`
23 if serializer.is_human_readable() {
24 serializer.collect_str(&parser::AsDisplay(flags))
25 }
26 // Serialize non-human-readable flags directly as the underlying bits
27 else {
28 flags.bits().serialize(serializer)
29 }
30}
31
32/**
33Deserialize a set of flags from a human-readable string or their underlying bits.

Callers

nothing calls this directly

Calls 2

AsDisplayClass · 0.85
bitsMethod · 0.45

Tested by

no test coverage detected