rsip/common/uri/param/branch.rs
1use rsip_derives::{IntoParam, NewType};
2
3/// Simple NewType around String. Intended to be used for the `branch` parameter found in the `Via`
4/// header.
5///
6/// Provides a simple default implementation that uses a `Uuid` for genearting a unique branch
7/// across space & time.
8#[derive(NewType, IntoParam, Debug, PartialEq, Eq, Clone)]
9pub struct Branch(String);
10
11impl<'a> Default for Branch {
12 fn default() -> Self {
13 use uuid::Uuid;
14 Self::new(format!("z9hG4bK-rsip-{}", Uuid::new_v4()))
15 }
16}
17
18#[cfg(feature = "test-utils")]
19impl testing_utils::Randomize for Branch {
20 fn random() -> Self {
21 Self::default()
22 }
23}