diff options
| author | mo khan <mo@mokhan.ca> | 2025-07-15 16:37:08 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2025-07-17 16:30:22 -0600 |
| commit | 45df4d0d9b577fecee798d672695fe24ff57fb1b (patch) | |
| tree | 1b99bf645035b58e0d6db08c7a83521f41f7a75b /vendor/itertools/src/powerset.rs | |
| parent | f94f79608393d4ab127db63cc41668445ef6b243 (diff) | |
feat: migrate from Cedar to SpiceDB authorization system
This is a major architectural change that replaces the Cedar policy-based
authorization system with SpiceDB's relation-based authorization.
Key changes:
- Migrate from Rust to Go implementation
- Replace Cedar policies with SpiceDB schema and relationships
- Switch from envoy `ext_authz` with Cedar to SpiceDB permission checks
- Update build system and dependencies for Go ecosystem
- Maintain Envoy integration for external authorization
This change enables more flexible permission modeling through SpiceDB's
Google Zanzibar inspired relation-based system, supporting complex
hierarchical permissions that were difficult to express in Cedar.
Breaking change: Existing Cedar policies and Rust-based configuration
will no longer work and need to be migrated to SpiceDB schema.
Diffstat (limited to 'vendor/itertools/src/powerset.rs')
| -rw-r--r-- | vendor/itertools/src/powerset.rs | 131 |
1 files changed, 0 insertions, 131 deletions
diff --git a/vendor/itertools/src/powerset.rs b/vendor/itertools/src/powerset.rs deleted file mode 100644 index 734eaf61..00000000 --- a/vendor/itertools/src/powerset.rs +++ /dev/null @@ -1,131 +0,0 @@ -use alloc::vec::Vec; -use std::fmt; -use std::iter::FusedIterator; - -use super::combinations::{combinations, Combinations}; -use crate::adaptors::checked_binomial; -use crate::size_hint::{self, SizeHint}; - -/// An iterator to iterate through the powerset of the elements from an iterator. -/// -/// See [`.powerset()`](crate::Itertools::powerset) for more -/// information. -#[must_use = "iterator adaptors are lazy and do nothing unless consumed"] -pub struct Powerset<I: Iterator> { - combs: Combinations<I>, -} - -impl<I> Clone for Powerset<I> -where - I: Clone + Iterator, - I::Item: Clone, -{ - clone_fields!(combs); -} - -impl<I> fmt::Debug for Powerset<I> -where - I: Iterator + fmt::Debug, - I::Item: fmt::Debug, -{ - debug_fmt_fields!(Powerset, combs); -} - -/// Create a new `Powerset` from a clonable iterator. -pub fn powerset<I>(src: I) -> Powerset<I> -where - I: Iterator, - I::Item: Clone, -{ - Powerset { - combs: combinations(src, 0), - } -} - -impl<I: Iterator> Powerset<I> { - /// Returns true if `k` has been incremented, false otherwise. - fn increment_k(&mut self) -> bool { - if self.combs.k() < self.combs.n() || self.combs.k() == 0 { - self.combs.reset(self.combs.k() + 1); - true - } else { - false - } - } -} - -impl<I> Iterator for Powerset<I> -where - I: Iterator, - I::Item: Clone, -{ - type Item = Vec<I::Item>; - - fn next(&mut self) -> Option<Self::Item> { - if let Some(elt) = self.combs.next() { - Some(elt) - } else if self.increment_k() { - self.combs.next() - } else { - None - } - } - - fn nth(&mut self, mut n: usize) -> Option<Self::Item> { - loop { - match self.combs.try_nth(n) { - Ok(item) => return Some(item), - Err(steps) => { - if !self.increment_k() { - return None; - } - n -= steps; - } - } - } - } - - fn size_hint(&self) -> SizeHint { - let k = self.combs.k(); - // Total bounds for source iterator. - let (n_min, n_max) = self.combs.src().size_hint(); - let low = remaining_for(n_min, k).unwrap_or(usize::MAX); - let upp = n_max.and_then(|n| remaining_for(n, k)); - size_hint::add(self.combs.size_hint(), (low, upp)) - } - - fn count(self) -> usize { - let k = self.combs.k(); - let (n, combs_count) = self.combs.n_and_count(); - combs_count + remaining_for(n, k).unwrap() - } - - fn fold<B, F>(self, mut init: B, mut f: F) -> B - where - F: FnMut(B, Self::Item) -> B, - { - let mut it = self.combs; - if it.k() == 0 { - init = it.by_ref().fold(init, &mut f); - it.reset(1); - } - init = it.by_ref().fold(init, &mut f); - // n is now known for sure because k >= 1 and all k-combinations have been generated. - for k in it.k() + 1..=it.n() { - it.reset(k); - init = it.by_ref().fold(init, &mut f); - } - init - } -} - -impl<I> FusedIterator for Powerset<I> -where - I: Iterator, - I::Item: Clone, -{ -} - -fn remaining_for(n: usize, k: usize) -> Option<usize> { - (k + 1..=n).try_fold(0usize, |sum, i| sum.checked_add(checked_binomial(n, i)?)) -} |
