パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v6.5.2

cbor

Dart用のCBORライブラリ。RFC8949準拠のCBORエンコード/デコード実装。

AndroidiOSWebmacOSWindowsLinux
30日間ダウンロード
32.2万
いいね数
41
Pub ポイント
160

パッケージをインストール

flutter pub add cbor

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

RFC8949準拠のCBOR(コンパクトなバイナリオブジェクト表現)データのエンコードおよびデコードを行うためのDartライブラリです。構造化されたデータを効率的にコンパクトなバイナリ形式にシリアライズでき、帯域幅とパフォーマンスが重要なIoT、モバイル、Webアプリケーションに最適です。このパッケージはすべての標準CBORタイプをサポートしており、Dartエコシステムとシームレスに統合されます。

用途

  • IoTデバイスにおける効率的なデータシリアル化
  • モバイルアプリにおけるコンパクトなペイロード伝送
  • CBOR を使用するシステムとの相互運用性
  • Web API データ交換
  • 軽量フォーマットにバイナリデータを埋め込む

主な機能

  • RFC8949準拠
  • すべてのCBORデータ型をサポートしています
  • 軽量なバイナリエンコーディング
  • クロスプラットフォーム互換性
  • エンコード/デコード用のシンプルな API
  • すべての主要プラットフォームで動作します

適している対象

  • コンパクトなデータ形式を必要とする開発者
  • 高性能シリアル化を必要とするアプリケーション
  • CBORを介して通信するシステム
  • 帯域制限のあるモバイルおよびウェブアプリ

注意事項

  • CBOR形式のみに制限
  • スキーマ検証の組み込みサポートなし
  • CBORの意味論を理解する必要があります
  • 人間が読み取り可能なデータには適していません

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

cbor

Build Status Pub Version

Documentation

This package provides an encoding/decoding package for the Concise Binary Object Representation as documented in RFC8949.

CBOR is increasingly used as a line protocol in the IOT world where the overhead of transmitting JSON on constrained devices can be large in packet size and processing overheads.

Features

  • Streamlined encoding and decoding of CBOR, including indefinite length and streamed decoding.
  • Set of types that semantically handles types, nesting, and tags.
  • Automatic conversion for the smallest size needed for integers.
  • Automatic conversion for the smallest precision needed for floating point numbers.
  • Any value can be the key for a map.
  • Optional simple API for encoding and decoding directly to Dart objects.
  • Pretty-printing and conversion to JSON.
  • Rational numbering encoding is supported on tag 30.

Usage

Two APIs are provided, cbor.dart and simple.dart.

cbor.dart

Encodes from CborValue and decodes to CborValue.

The CborValue contains the tags for this item, and its subtypes are used to identify the type and tags for the item. This allows one to handle information encoded in a more lossless way.

Inheritance tree for CborValue looks something like this:

CborValue
├── CborInt
│   ├── CborSmallInt
│   └── CborDateTimeInt
├── CborBytes
│   └── CborBigInt
├── CborString
│   ├── CborDateTimeString
│   ├── CborBase64
│   ├── CborBase64Url
│   ├── CborMime
│   └── CborRegex
├── CborFloat
│   └── CborDateTimeFloat
├── CborSimpleValue
│   ├── CborNull
│   ├── CborBool
│   └── CborUndefined
├── CborMap
└── CborList
    ├── CborDecimalFraction
    ├── CborRationalNumber
    └── CborBigFloat
Example
import 'package:cbor/cbor.dart';

test('{1:2,3:4}', () {
   final encoded = cbor.encode(CborMap({
      CborSmallInt(1): CborSmallInt(2),
      CborSmallInt(3): CborSmallInt(4),
   }));
   expect(encoded, [0xa2, 0x01, 0x02, 0x03, 0x04]);
});

Check out the example folder for more examples.

simple.dart

Less powerful, but may be the best option for simple applications that do not need any of the fancy features of the cbor API above.

The encoder in simple API will operate similarly to constructing a CborValue from the input and the encoding it.

Decoder will translate the input to a common Dart object, ignoring any extra tags after the type is decided.

Example
import 'package:cbor/simple.dart';

test('{1:2,3:4}', () {
   final encoded = cbor.encode({
      1: 2,
      3: 4,
   });
   expect(encoded, [0xa2, 0x01, 0x02, 0x03, 0x04]);
});
Additional RFC's implemented

The following CBOR RFC's have also been implemented in the package :-

  • RFC8746 - Concise Binary Object Representation (CBOR) Tags for Typed Arrays.

カテゴリー

依存関係

依存関係一覧 6 件

ソースリポジトリ

このパッケージを使用しているプロジェクト