/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "nsISupports.idl"

/**
 * A consumer of a filter cascade, i.e. a cascaded bloom filter as generated by
 * https://github.com/mozilla/filter-cascade
 */
[scriptable, uuid(c8d0b0b3-17f8-458b-9264-7b67b288fe79)]
interface nsICascadeFilter : nsISupports {
  /**
   * Initialize with the data that represents the filter cascade.
   * This method can be called repeatedly.
   *
   * @throws NS_ERROR_INVALID_ARG if the input is malformed.
   */
  void setFilterData(in Array<octet> data);

  /**
   * Check whether a given key is a member of the filter cascade.
   * The result can only be relied upon if the key was known at the time of the
   * filter generation. If the key is unknown, the method may incorrectly
   * return true (due to the probabilistic nature of bloom filters).
   */
  boolean has(in ACString key);
};
