comparison rust/hg-cpython/src/cindex.rs @ 48853:4346be456875

rust: implement vcsgraph::RankedGraph for Index Differential Revision: https://phab.mercurial-scm.org/D12210
author pacien <pacien.trangirard@pacien.net>
date Mon, 21 Feb 2022 18:06:02 +0100
parents e633e660158f
children 3aca98a35727
comparison
equal deleted inserted replaced
48852:e633e660158f 48853:4346be456875
175 ), 175 ),
176 } 176 }
177 } 177 }
178 } 178 }
179 179
180 impl vcsgraph::graph::RankedGraph for Index {
181 fn rank(
182 &self,
183 rev: Revision,
184 ) -> Result<vcsgraph::graph::Rank, vcsgraph::graph::GraphReadError> {
185 match unsafe {
186 (self.capi.fast_rank)(self.index.as_ptr(), rev as ssize_t)
187 } {
188 -1 => Err(vcsgraph::graph::GraphReadError::InconsistentGraphData),
189 rank => Ok(rank as usize),
190 }
191 }
192 }
193
180 impl RevlogIndex for Index { 194 impl RevlogIndex for Index {
181 /// Note C return type is Py_ssize_t (hence signed), but we shall 195 /// Note C return type is Py_ssize_t (hence signed), but we shall
182 /// force it to unsigned, because it's a length 196 /// force it to unsigned, because it's a length
183 fn len(&self) -> usize { 197 fn len(&self) -> usize {
184 unsafe { (self.capi.index_length)(self.index.as_ptr()) as usize } 198 unsafe { (self.capi.index_length)(self.index.as_ptr()) as usize }