@@ -5,30 +5,30 @@ use crate::{Error, Fragment, Origin, RedapUri, TimeSelection};
55/// URI pointing at the data underlying a dataset.
66///
77/// Currently, the following format is supported:
8- /// `<origin>/dataset/$DATASET_ID/data?partition_id=$PARTITION_ID &time_range=$TIME_RANGE`
8+ /// `<origin>/dataset/$DATASET_ID/data?segment_id=$SEGMENT_ID &time_range=$TIME_RANGE`
99///
10- /// `partition_id ` is currently mandatory, and `time_range` is optional.
10+ /// `segment_id ` is currently mandatory, and `time_range` is optional.
1111/// In the future we will add richer queries.
1212#[ derive( Clone , Debug , PartialEq , Eq , Hash ) ]
13- pub struct DatasetPartitionUri {
13+ pub struct DatasetSegmentUri {
1414 pub origin : Origin ,
1515 pub dataset_id : re_tuid:: Tuid ,
1616
1717 // Query parameters: these affect what data is returned.
1818 /// Currently mandatory.
19- pub partition_id : String ,
19+ pub segment_id : String ,
2020 pub time_range : Option < TimeSelection > ,
2121
2222 // Fragment parameters: these affect what the viewer focuses on:
2323 pub fragment : Fragment ,
2424}
2525
26- impl std:: fmt:: Display for DatasetPartitionUri {
26+ impl std:: fmt:: Display for DatasetSegmentUri {
2727 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
2828 let Self {
2929 origin,
3030 dataset_id,
31- partition_id ,
31+ segment_id ,
3232 time_range,
3333 fragment,
3434 } = self ;
@@ -37,7 +37,7 @@ impl std::fmt::Display for DatasetPartitionUri {
3737
3838 // ?query:
3939 {
40- write ! ( f, "?partition_id={partition_id }" ) ?;
40+ write ! ( f, "?segment_id={segment_id }" ) ?;
4141 }
4242 if let Some ( time_range) = time_range {
4343 write ! ( f, "&time_range={time_range}" ) ?;
@@ -53,15 +53,21 @@ impl std::fmt::Display for DatasetPartitionUri {
5353 }
5454}
5555
56- impl DatasetPartitionUri {
56+ impl DatasetSegmentUri {
5757 pub fn new ( origin : Origin , dataset_id : re_tuid:: Tuid , url : & url:: Url ) -> Result < Self , Error > {
58- let mut partition_id = None ;
58+ let mut segment_id = None ;
59+ let mut legacy_partition_id = None ;
5960 let mut time_range = None ;
6061
6162 for ( key, value) in url. query_pairs ( ) {
6263 match key. as_ref ( ) {
64+ // Accept legacy `partition_id` query parameter.
6365 "partition_id" => {
64- partition_id = Some ( value. to_string ( ) ) ;
66+ legacy_partition_id = Some ( value. to_string ( ) ) ;
67+ }
68+
69+ "segment_id" => {
70+ segment_id = Some ( value. to_string ( ) ) ;
6571 }
6672 "time_range" => {
6773 // `+` means whitespace in URLs.
@@ -75,8 +81,16 @@ impl DatasetPartitionUri {
7581 }
7682 }
7783
78- let Some ( partition_id) = partition_id else {
79- return Err ( Error :: MissingPartitionId ) ;
84+ let segment_id = match ( segment_id, legacy_partition_id) {
85+ ( Some ( s) , None ) | ( None , Some ( s) ) => s,
86+
87+ ( None , None ) => {
88+ return Err ( Error :: MissingSegmentId ) ;
89+ }
90+
91+ ( Some ( _) , Some ( _) ) => {
92+ return Err ( Error :: AmbiguousSegmentId ) ;
93+ }
8094 } ;
8195
8296 let mut fragment = Fragment :: default ( ) ;
@@ -87,7 +101,7 @@ impl DatasetPartitionUri {
87101 Ok ( Self {
88102 origin,
89103 dataset_id,
90- partition_id ,
104+ segment_id ,
91105 time_range,
92106 fragment,
93107 } )
@@ -96,9 +110,9 @@ impl DatasetPartitionUri {
96110 /// Returns [`Self`] without any (optional) `?query` or `#fragment`.
97111 pub fn without_query_and_fragment ( mut self ) -> Self {
98112 let Self {
99- origin : _, // Mandatory
100- dataset_id : _, // Mandatory
101- partition_id : _, // Mandatory
113+ origin : _, // Mandatory
114+ dataset_id : _, // Mandatory
115+ segment_id : _, // Mandatory
102116 time_range,
103117 fragment,
104118 } = & mut self ;
@@ -112,9 +126,9 @@ impl DatasetPartitionUri {
112126 /// Returns [`Self`] without any (optional) `#fragment`.
113127 pub fn without_fragment ( mut self ) -> Self {
114128 let Self {
115- origin : _, // Mandatory
116- dataset_id : _, // Mandatory
117- partition_id : _, // Mandatory
129+ origin : _, // Mandatory
130+ dataset_id : _, // Mandatory
131+ segment_id : _, // Mandatory
118132 time_range : _,
119133 fragment,
120134 } = & mut self ;
@@ -128,12 +142,12 @@ impl DatasetPartitionUri {
128142 StoreId :: new (
129143 re_log_types:: StoreKind :: Recording ,
130144 self . dataset_id . to_string ( ) ,
131- self . partition_id . clone ( ) ,
145+ self . segment_id . clone ( ) ,
132146 )
133147 }
134148}
135149
136- impl std:: str:: FromStr for DatasetPartitionUri {
150+ impl std:: str:: FromStr for DatasetSegmentUri {
137151 type Err = Error ;
138152
139153 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
@@ -148,7 +162,7 @@ impl std::str::FromStr for DatasetPartitionUri {
148162// --------------------------------
149163
150164// Serialize as string:
151- impl serde:: Serialize for DatasetPartitionUri {
165+ impl serde:: Serialize for DatasetSegmentUri {
152166 fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
153167 where
154168 S : serde:: Serializer ,
@@ -157,7 +171,7 @@ impl serde::Serialize for DatasetPartitionUri {
157171 }
158172}
159173
160- impl < ' de > serde:: Deserialize < ' de > for DatasetPartitionUri {
174+ impl < ' de > serde:: Deserialize < ' de > for DatasetSegmentUri {
161175 fn deserialize < D > ( deserializer : D ) -> Result < Self , D :: Error >
162176 where
163177 D : serde:: Deserializer < ' de > ,
0 commit comments