This commit is contained in:
robin-nitrokey
2024-10-21 13:47:00 +00:00
parent d3b7289ce0
commit 39d77774c1
13 changed files with 30 additions and 93 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
window.SIDEBAR_ITEMS = {"fn":["cbor_deserialize","cbor_serialize","cbor_serialize_bytes","cbor_serialize_extending_bytes","cbor_serialize_to"],"mod":["de","error","ser"]};
window.SIDEBAR_ITEMS = {"fn":["cbor_deserialize","cbor_serialize","cbor_serialize_to"],"mod":["de","error","ser"]};
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1 +1 @@
searchState.loadedDescShard("cbor_smol", 0, "Serialize object into newly allocated Bytes.\nAppend serialization of object to existing bytes, …\nSerialize an object to a <code>Writer</code>\nA structure for deserializing a cbor-smol message.\nReturns the argument unchanged.\nDeserialize a message of type <code>T</code> from a byte slice. The …\nObtain a Deserializer from a slice of bytes\nCalls <code>U::from(self)</code>.\nDeserialize a message of type <code>T</code> from a byte slice. The …\nFound a bool that wasnt 0xf4 or 0xf5\nCould not parse an enum\nExpected a i16, was too large\nExpected a i32, was too large\nExpected a i64, was too large\nExpected a i8, was too large\nExpected a different major type\nExpected a u16\nExpected a u32\nExpected a u64\nExpected a u8\nTried to parse invalid utf-8\nExpected a NULL marker\nValue may be valid, but not encoded in minimal way\nHit the end of buffer, expected more data\nContains the error value\nThis is the error type used by cbor-smol\nInexistent slice-to-array cast error. Used here to avoid …\nThis is a feature that cbor-smol intends to support, but …\nContains the success value\nThis is the Result type used by cbor-smol.\nSerde Deserialization Error\nSerde Missing required value\nSerde Serialization Error\nThe serialize buffer is full\nThis is a feature that cbor-smol will never implement\nReturns the argument unchanged.\nCalls <code>U::from(self)</code>.\nThe type of error returned when a write operation fails.\nReturns the argument unchanged.\nCalls <code>U::from(self)</code>.\nUnwrap the <code>Writer</code> from the <code>Serializer</code>.\nAttempts to write an entire buffer into this write.")
searchState.loadedDescShard("cbor_smol", 0, "Serialize an object to a <code>Writer</code>\nA structure for deserializing a cbor-smol message.\nReturns the argument unchanged.\nDeserialize a message of type <code>T</code> from a byte slice. The …\nObtain a Deserializer from a slice of bytes\nCalls <code>U::from(self)</code>.\nDeserialize a message of type <code>T</code> from a byte slice. The …\nFound a bool that wasnt 0xf4 or 0xf5\nCould not parse an enum\nExpected a i16, was too large\nExpected a i32, was too large\nExpected a i64, was too large\nExpected a i8, was too large\nExpected a different major type\nExpected a u16\nExpected a u32\nExpected a u64\nExpected a u8\nTried to parse invalid utf-8\nExpected a NULL marker\nValue may be valid, but not encoded in minimal way\nHit the end of buffer, expected more data\nContains the error value\nThis is the error type used by cbor-smol\nInexistent slice-to-array cast error. Used here to avoid …\nThis is a feature that cbor-smol intends to support, but …\nContains the success value\nThis is the Result type used by cbor-smol.\nSerde Deserialization Error\nSerde Missing required value\nSerde Serialization Error\nThe serialize buffer is full\nThis is a feature that cbor-smol will never implement\nReturns the argument unchanged.\nCalls <code>U::from(self)</code>.\nThe type of error returned when a write operation fails.\nReturns the argument unchanged.\nCalls <code>U::from(self)</code>.\nUnwrap the <code>Writer</code> from the <code>Serializer</code>.\nAttempts to write an entire buffer into this write.")
-54
View File
@@ -38,33 +38,6 @@
<a href="#38" id="38">38</a>
<a href="#39" id="39">39</a>
<a href="#40" id="40">40</a>
<a href="#41" id="41">41</a>
<a href="#42" id="42">42</a>
<a href="#43" id="43">43</a>
<a href="#44" id="44">44</a>
<a href="#45" id="45">45</a>
<a href="#46" id="46">46</a>
<a href="#47" id="47">47</a>
<a href="#48" id="48">48</a>
<a href="#49" id="49">49</a>
<a href="#50" id="50">50</a>
<a href="#51" id="51">51</a>
<a href="#52" id="52">52</a>
<a href="#53" id="53">53</a>
<a href="#54" id="54">54</a>
<a href="#55" id="55">55</a>
<a href="#56" id="56">56</a>
<a href="#57" id="57">57</a>
<a href="#58" id="58">58</a>
<a href="#59" id="59">59</a>
<a href="#60" id="60">60</a>
<a href="#61" id="61">61</a>
<a href="#62" id="62">62</a>
<a href="#63" id="63">63</a>
<a href="#64" id="64">64</a>
<a href="#65" id="65">65</a>
<a href="#66" id="66">66</a>
<a href="#67" id="67">67</a>
</pre></div><pre class="rust"><code><span class="attr">#![cfg_attr(not(test), no_std)]
#[macro_use]
@@ -101,33 +74,6 @@
<span class="prelude-val">Ok</span>(<span class="kw-2">&amp;</span>buffer[..written])
}
<span class="attr">#[cfg(feature = <span class="string">"heapless-bytes-v0-3"</span>)]
#[deprecated(note = <span class="string">"use `cbor_serialize_to` instead"</span>)]
</span><span class="doccomment">/// Append serialization of object to existing bytes, returning length of serialized object.
</span><span class="kw">pub fn </span>cbor_serialize_extending_bytes&lt;T: <span class="question-mark">?</span>Sized + serde::Serialize, <span class="kw">const </span>N: usize&gt;(
object: <span class="kw-2">&amp;</span>T,
bytes: <span class="kw-2">&amp;mut </span>heapless_bytes_v0_3::Bytes&lt;N&gt;,
) -&gt; <span class="prelude-ty">Result</span>&lt;usize&gt; {
<span class="kw">let </span>len_before = bytes.len();
<span class="kw">let </span>vec: <span class="kw-2">&amp;mut </span>heapless_v0_7::Vec&lt;u8, N&gt; = bytes;
<span class="kw">let </span><span class="kw-2">mut </span>ser = ser::Serializer::new(vec);
object.serialize(<span class="kw-2">&amp;mut </span>ser)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(ser.into_inner().len() - len_before)
}
<span class="attr">#[cfg(feature = <span class="string">"heapless-bytes-v0-3"</span>)]
</span><span class="doccomment">/// Serialize object into newly allocated Bytes.
</span><span class="kw">pub fn </span>cbor_serialize_bytes&lt;T: <span class="question-mark">?</span>Sized + serde::Serialize, <span class="kw">const </span>N: usize&gt;(
object: <span class="kw-2">&amp;</span>T,
) -&gt; <span class="prelude-ty">Result</span>&lt;heapless_bytes_v0_3::Bytes&lt;N&gt;&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>data = heapless_bytes_v0_3::Bytes::&lt;N&gt;::new();
<span class="attr">#[allow(deprecated)]
</span>cbor_serialize_extending_bytes(object, <span class="kw-2">&amp;mut </span>data)<span class="question-mark">?</span>;
<span class="prelude-val">Ok</span>(data)
}
<span class="kw">pub fn </span>cbor_deserialize&lt;<span class="lifetime">'de</span>, T: serde::Deserialize&lt;<span class="lifetime">'de</span>&gt;&gt;(buffer: <span class="kw-2">&amp;</span><span class="lifetime">'de </span>[u8]) -&gt; <span class="prelude-ty">Result</span>&lt;T&gt; {
<span class="comment">// cortex_m_semihosting::hprintln!("deserializing {:?}", buffer).ok();
</span>de::from_bytes(buffer)