MCPcopy Create free account
hub / github.com/ElementsProject/lightning / from_bytes_auto

Method from_bytes_auto

plugins/lsps-plugin/src/core/tlv.rs:116–124  ·  view source on GitHub ↗

Attempt to auto-detect whether the input has a length prefix or not First tries to parse as length-prefixed, then falls back to raw TLV parsing.

(bytes: &[u8])

Source from the content-addressed store, hash-verified

114 /// First tries to parse as length-prefixed, then falls back to raw TLV
115 /// parsing.
116 pub fn from_bytes_auto(bytes: &[u8]) -> Result<Self> {
117 // Try length-prefixed first
118 if let Ok(stream) = Self::from_bytes_with_length_prefix(bytes) {
119 return Ok(stream);
120 }
121
122 // Fall back to raw TLV parsing
123 Self::from_bytes(bytes)
124 }
125
126 /// Get a reference to the value of a TLV record by type.
127 pub fn get(&self, type_: u64) -> Option<&[u8]> {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected