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/signature/src/encoding.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 / signature / src / encoding.rs` 31 lines ยท 835 bytes Raw Blame History 1 //! Encoding support. 2 3 #[cfg(feature = "alloc")] 4 use alloc::vec::Vec; 5 6 /// Support for decoding/encoding signatures as bytes. 7 pub trait SignatureEncoding: 8 Clone + Sized + for<'a> TryFrom<&'a [u8]> + TryInto 9 { 10 /// Byte representation of a signature. 11 type Repr: 'static + AsRef<[u8]> + Clone + Send + Sync; 12 13 /// Encode signature as its byte representation. 14 fn to_bytes(&self) -> Self::Repr { 15 self.clone() 16 .try_into() 17 .ok() 18 .expect("signature encoding error") 19 } 20 21 /// Encode signature as a byte vector. 22 #[cfg(feature = "alloc")] 23 fn to_vec(&self) -> Vec { 24 self.to_bytes().as_ref().to_vec() 25 } 26 27 /// Get the length of this signature when encoded. 28 fn encoded_len(&self) -> usize { 29 self.to_bytes().as_ref().len() 30 } 31 }