re_log_encoding/
lib.rs

1//! This crate covers two equally important but orthogonal matters:
2//! * Converting between transport-level and application-level Rerun types.
3//! * Encoding and decoding Rerun RRD streams.
4//!
5//! If you are working with one of the gRPC APIs (Redap or SDK comms), then you want to be looking
6//! at the [`ToTransport`]/[`ToApplication`] traits. The [`rrd`] module is completely irrelevant in
7//! that case. You can learn more about these traits below.
8//!
9//! If you are working with actual RRD streams (i.e. everything that does not go through gRPC:
10//! files, standard I/O, HTTP, data loaders, etc), then have a look into the [`rrd`] module.
11//! The [`ToTransport`]/[`ToApplication`] traits will also be useful to you. You can learn more
12//! about these traits below.
13//!
14//! ## What are transport-level and application-level types?
15//!
16//! To put it in simple terms: transport-level types are the types that you find in `re_protos`, while
17//! application-level types are those that you find in `re_log_types`.
18//!
19//! More generally, transport-level types are Rust objects that represent the decoded value of some
20//! Rerun bytes, *and nothing more than that*. It's all they do: they map raw bytes to their native
21//! Rust representation and vice-versa. They never apply any application-level logic beyond that.
22//!
23//! Transport-level types are used to unopinionatedly transport Rerun data across the many mediums
24//! that Rerun support, while application-level types are used to build applications for end-users,
25//! such as the Rerun viewer itself.
26//!
27//! Application-level types on the other hand are *very* opinionated, and often perform a lot of
28//! transformations on the data, including but not limited to:
29//! * Chunk/Sorbet migrations
30//! * Application ID injection
31//! * SDK version patching
32//! * Backward-compatibility shenanigans
33//! * Etc
34//!
35//! Application-level can _not_ be encoded/decoded, only transport-level types can. To encode an
36//! application-level type, you must first convert it to transport-level type.
37//! You can do so by using the [`ToApplication`] & [`ToTransport`] traits exposed by this crate.
38//!
39//! ## How do I make sense of all these different `LogMsg` types?!
40//!
41//! There are 3 different `LogMsg`-related types that you will very often encounter: `re_log_types::LogMsg`,
42//! `re_protos::log_msg::v1alpha1::LogMsg` and `re_protos::log_msg::v1alpha1::log_msg::Msg`.
43//!
44//! Mixing them up is a common source of pain and confusion, so let's go over what each does:
45//! * `re_log_types::LogMsg` is the application-level type that we use all across the viewer
46//!   codebase. It can be obtained by calling `to_application()` on one of the transport-level
47//!   `LogMsg` types which, among many other things, will perform Chunk/Sorbet-level migrations.
48//!   `re_log_types::LogMsg` isn't used in Redap, where everything is done at the transport-level, always.
49//! * `re_protos::log_msg::v1alpha1::LogMsg` is the transport-level definition of `LogMsg`. It is an
50//!   artifact of how `oneof` works in Protobuf: all it does is carry a `re_protos::log_msg::v1alpha1::log_msg::Msg`.
51//!   For that reason, it is never directly used, except by the legacy SDK comms protocol.
52//! * Finally, `re_protos::log_msg::v1alpha1::log_msg::Msg` is the real transport-level type that we
53//!   care about. It is used all over the place when encoding and decoding RRD streams.
54//!
55//! ## What are the different protocols supported by Rerun?
56//!
57//! Rerun currently supports 3 protocols:
58//! * Redap (Rerun Data Protocol): our gRPC-based protocol used by our OSS and proprietary data platforms.
59//! * SDK comms: our legacy gRPC-based protocol, currently used by everything relying on the old
60//!   `StoreHub` model (logging, message proxy, etc).
61//! * RRD streams: the binary protocol that we use for all stream-based interfaces (files, stdio,
62//!   data-loaders, HTTP fetches, etc).
63//!
64//! *All these protocols use the exact same encoding*. There is only one encoding: the Rerun encoding.
65//! It often happens that one protocol makes use of some types while others don't (e.g. the
66//! top-level `LogMsg` object is never used in RRD streams, but is used in SDK comms), but for all
67//! the types they do share, the encoding will be the exact same.
68
69pub mod rrd;
70
71mod app_id_injector;
72mod transport_to_app;
73
74pub mod external {
75    pub use lz4_flex;
76}
77
78pub use self::app_id_injector::{
79    ApplicationIdInjector, CachingApplicationIdInjector, DummyApplicationIdInjector,
80};
81pub use self::rrd::*;
82pub use self::transport_to_app::{ToApplication, ToTransport};