cbor

Serialize fixed size Map to CBOR

荒凉一梦 提交于 2020-03-01 06:43:18
问题 I have the following JSON: [ { 2: { "c": true } }, { 3: { "p": 10 } } ] That I would like to convert to CBOR format. Accordingly to cbor.me I have the following output: 82A102A16163F5A103A161700A But, when using Jackson Binary CBOR Serializer, I have the following output: 82BF02BF6163F5FFFFBF03BF61700AFFFF Which is not wrong, but not optimized... I have an extra 4 unnecessary bytes added to what it can really be. I've then tried to manually serialize the JSON but same result: @Override public

WebAuthn - byte length of the “credential public key”

↘锁芯ラ 提交于 2020-01-25 02:49:07
问题 In WebAuthn, the authenticator data contains the variable length attested credential data followed by the extensions , if any: The attested credential data is made variable because of the credential public key field which is a CBOR map. In case there are extensions, how to know in advance the byte length of this field, so that I can pass this field truncated without the extensions to a CBOR library? The CBOR library I am using doesn't seem to handle extra bytes, and I don't know CBOR enough

Comparing uint64_t and float for numeric equivalence

烂漫一生 提交于 2020-01-11 09:44:08
问题 I am writing a protocol, that uses RFC 7049 as its binary representation. The standard states, that the protocol may use 32-bit floating point representation of numbers, if their numeric value is equivalent to respective 64-bit numbers. The conversion must not lead to lose of precision. What 32-bit float numbers can be bigger than 64-bit integer and numerically equivalent with them? Is comparing float x; uint64_t y; (float)x == (float)y enough for ensuring, that the values are equivalent?

es的接口说明

拥有回忆 提交于 2019-11-30 18:04:16
_cat接口: 接口格式: curl -XGET http://localhost:9200/_cat/$command 如果只想查看某个索引库的信息,在后面再加上库名即可: curl -XGET http://localhost:9200/_cat/$command/$indexname 例如查看文档数量: curl -XGET http://localhost:9200/_cat/count 只查看某个索引库文档数量: curl -XGET http://localhost:9200/_cat/count/$indexname 查看所有支持的命令 : curl -XGET http://localhost:9200/_cat 打开verbose: curl -XGET http://localhost:9200/_cat/$command?v 查看输出结果列的说明: curl -XGET http://localhost:9200/_cat/$command?help 只输出指定的列: curl -XGET http://localhost:9200/_cat/$command?h=ip,port,name 各类数字格式指定: 默认会输出可读格式,可以强制使用数字格式方便排序: curl 'http://localhost:9200/_cat/indices?bytes=b

How do I deserialize into trait, not a concrete type?

杀马特。学长 韩版系。学妹 提交于 2019-11-30 08:21:24
问题 I'm trying to do struct serialization, in which the bytes would eventually be sent down a pipe, reconstructed and methods be called on them. I created a trait these structs would implement as appropriate and I'm using serde and serde-cbor for serialization: extern crate serde_cbor; #[macro_use] extern crate serde_derive; extern crate serde; use serde_cbor::ser::*; use serde_cbor::de::*; trait Contract { fn do_something(&self); } #[derive(Debug, Serialize, Deserialize)] struct Foo { x: u32, y:

How do I deserialize into trait, not a concrete type?

主宰稳场 提交于 2019-11-29 06:27:02
I'm trying to do struct serialization, in which the bytes would eventually be sent down a pipe, reconstructed and methods be called on them. I created a trait these structs would implement as appropriate and I'm using serde and serde-cbor for serialization: extern crate serde_cbor; #[macro_use] extern crate serde_derive; extern crate serde; use serde_cbor::ser::*; use serde_cbor::de::*; trait Contract { fn do_something(&self); } #[derive(Debug, Serialize, Deserialize)] struct Foo { x: u32, y: u32, } #[derive(Debug, Serialize, Deserialize)] struct Bar { data: Vec<Foo>, } #[derive(Debug,