Skip to content

Commit

Permalink
feat: put unrecognized encoding string in schema of "zenoh/bytes" (#1102
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wyfo authored Jun 10, 2024
1 parent 04f05cb commit 00264bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions zenoh/src/api/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,13 @@ impl From<&str> for Encoding {
}

// Everything before `;` may be mapped to a known id
let (id, schema) = t.split_once(Encoding::SCHEMA_SEP).unwrap_or((t, ""));
let (id, mut schema) = t.split_once(Encoding::SCHEMA_SEP).unwrap_or((t, ""));
if let Some(id) = Encoding::STR_TO_ID.get(id).copied() {
inner.id = id;
};
// if id is not recognized, e.g. `t == "my_encoding"`, put it in the schema
} else {
schema = t;
}
if !schema.is_empty() {
inner.schema = Some(ZSlice::from(schema.to_string().into_bytes()));
}
Expand Down

0 comments on commit 00264bf

Please sign in to comment.