Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/der/src/asn1/choice.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / der / src / asn1 / choice.rs` 26 lines ยท 777 bytes Raw Blame History 1 //! ASN.1 `CHOICE` support. 2 3 use crate::{Decode, FixedTag, Tag, Tagged}; 4 5 /// ASN.1 `CHOICE` denotes a union of one or more possible alternatives. 6 /// 7 /// The types MUST have distinct tags. 8 /// 9 /// This crate models choice as a trait, with a blanket impl for all types 10 /// which impl `Decode + FixedTag` (i.e. they are modeled as a `CHOICE` 11 /// with only one possible variant) 12 pub trait Choice<'a>: Decode<'a> + Tagged { 13 /// Is the provided [`Tag`] decodable as a variant of this `CHOICE`? 14 fn can_decode(tag: Tag) -> bool; 15 } 16 17 /// This blanket impl allows any [`Tagged`] type to function as a [`Choice`] 18 /// with a single alternative. 19 impl<'a, T> Choice<'a> for T 20 where 21 T: Decode<'a> + FixedTag, 22 { 23 fn can_decode(tag: Tag) -> bool { 24 T::TAG == tag 25 } 26 }