pub struct Polls<'a> { /* private fields */ }Implementations§
Source§impl<'a> Polls<'a>
impl<'a> Polls<'a>
Sourcepub async fn create(
&self,
to: impl Into<Jid>,
name: &str,
options: &[String],
selectable_count: u32,
) -> Result<(SendResult, Vec<u8>), PollError>
pub async fn create( &self, to: impl Into<Jid>, name: &str, options: &[String], selectable_count: u32, ) -> Result<(SendResult, Vec<u8>), PollError>
Caller needs the returned message_secret to decrypt votes.
Sourcepub async fn create_quiz(
&self,
to: impl Into<Jid>,
name: &str,
options: &[String],
correct_index: usize,
) -> Result<(SendResult, Vec<u8>), PollError>
pub async fn create_quiz( &self, to: impl Into<Jid>, name: &str, options: &[String], correct_index: usize, ) -> Result<(SendResult, Vec<u8>), PollError>
Create a quiz poll: a single-select poll with exactly one correct option.
correct_index is the 0-based index into options of the right answer.
Quizzes are inherently single-select (WA Web forces selectableOptionsCount=1),
so the count is fixed at 1. Returns the message_secret needed to decrypt votes.
pub async fn vote( &self, chat_jid: impl Into<Jid>, poll_msg_id: &str, poll_creator_jid: &Jid, message_secret: &[u8], option_names: &[String], ) -> Result<SendResult, PollError>
Sourcepub async fn decrypt_vote(
&self,
ciphertext: PollVoteCiphertext<'_>,
message_secret: &[u8],
poll_msg_id: &str,
poll_creator_jid: &Jid,
voter_jid: &Jid,
) -> Result<Vec<Vec<u8>>, PollError>
pub async fn decrypt_vote( &self, ciphertext: PollVoteCiphertext<'_>, message_secret: &[u8], poll_msg_id: &str, poll_creator_jid: &Jid, voter_jid: &Jid, ) -> Result<Vec<Vec<u8>>, PollError>
Selected option hashes (32 bytes each). Retries under the opposite
namespace (LID/PN) when a counterpart is known, so votes authored across
the LID migration still open. Mirrors WA Web WAWebAddonEncryption.
Sourcepub async fn aggregate_votes(
&self,
poll_options: &[String],
votes: &[(&Jid, PollVoteCiphertext<'_>)],
message_secret: &[u8],
poll_msg_id: &str,
poll_creator_jid: &Jid,
) -> Result<Vec<PollOptionResult>, PollError>
pub async fn aggregate_votes( &self, poll_options: &[String], votes: &[(&Jid, PollVoteCiphertext<'_>)], message_secret: &[u8], poll_msg_id: &str, poll_creator_jid: &Jid, ) -> Result<Vec<PollOptionResult>, PollError>
Decrypts each vote and tallies per-option results.
Later votes from the same voter replace earlier ones (last-vote-wins).
votes should be ordered oldest-first.
Dedupes voters by their canonical (LID-preferred) identity so a voter who re-votes under the other namespace after migrating replaces, rather than duplicates, their earlier vote.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Polls<'a>
impl<'a> !UnwindSafe for Polls<'a>
impl<'a> Freeze for Polls<'a>
impl<'a> Send for Polls<'a>
impl<'a> Sync for Polls<'a>
impl<'a> Unpin for Polls<'a>
impl<'a> UnsafeUnpin for Polls<'a>
Blanket Implementations§
Source§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
Source§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read moreSource§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read moreSource§fn aggregate_filter<P>(self, f: P) -> Self::Output
fn aggregate_filter<P>(self, f: P) -> Self::Output
Source§fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
fn aggregate_order<O>(self, o: O) -> Self::Outputwhere
Self: OrderAggregateDsl<O>,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self to an expression for Diesel’s query builder. Read more