Skip to content

rust: define blob key encoding #4545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 13, 2021
Merged

rust: define blob key encoding #4545

merged 4 commits into from
Jan 13, 2021

Conversation

wchargin
Copy link
Contributor

Summary:
The data provider RPC protocol requires servers to emit “blob keys”,
opaque, URL-safe tokens that uniquely identify blobs. This patch defines
an in-memory BlobKey struct with encoding and decoding. The wire
format is URL-safe base64 (with no padding) over JSON.

The seemingly unrelated changes are needed because loading serde_json
adds trait implementations that make some type inference inadmissible:
rust-lang/rust#80964

Test Plan:
Unit tests included.

wchargin-branch: rust-blob-keys

Summary:
The data provider RPC protocol requires servers to emit “blob keys”,
opaque, URL-safe tokens that uniquely identify blobs. This patch defines
an in-memory `BlobKey` struct with encoding and decoding. The wire
format is URL-safe base64 (with no padding) over JSON.

The seemingly unrelated changes are needed because loading `serde_json`
adds trait implementations that make some type inference inadmissible:
<rust-lang/rust#80964>

Test Plan:
Unit tests included.

wchargin-branch: rust-blob-keys
wchargin-source: bd9d325a73fb7757b2916e52a72c4e23255c51ed
@wchargin wchargin added the core:rustboard //tensorboard/data/server/... label Jan 13, 2021
@google-cla google-cla bot added the cla: yes label Jan 13, 2021
wchargin-branch: rust-blob-keys
wchargin-source: 7304b8f1f4e401a934083c5f25bba2a02fc42c61
@wchargin wchargin requested a review from stephanwlee January 13, 2021 20:03
fn test_bad_json() {
match "AAAAAA".parse::<BlobKey>().unwrap_err() {
ParseBlobKeyError::BadJson(_) => (),
other => panic!("expected BadBase64(_), got {:?}", other),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BadBase64 -> BadJson?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed; thanks!

wchargin-branch: rust-blob-keys
wchargin-source: 9e65e8c74746e97e09f5213d46d6d2a022d49af6
wchargin-branch: rust-blob-keys
wchargin-source: 9e65e8c74746e97e09f5213d46d6d2a022d49af6
@wchargin wchargin merged commit 012b901 into master Jan 13, 2021
@wchargin wchargin deleted the wchargin-rust-blob-keys branch January 13, 2021 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes core:rustboard //tensorboard/data/server/...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants