pub enum IdentityStrategy {
CreateIfNotFound {
inbox_id: String,
identifier: Identifier,
nonce: u64,
},
CreateForIdentifier {
identifier: Identifier,
nonce: u64,
},
CachedOnly,
}Expand description
The identity strategy determines how the xmtp_mls::builder::ClientBuilder constructs an identity on startup.
IdentityStrategy::CreateIfNotFound will attempt to create a new identity if one isn’t found in the store.
This is the default behavior.
IdentityStrategy::CreateForIdentifier acts as CreateIfNotFound for the inbox of an identifier,
which the builder asks the backend for only after it has checked the backend’s deployment.
IdentityStrategy::CachedOnly will attempt to get an identity from the store. If not found, it will
return an error. This is useful if you don’t want to create a new identity on startup because the caller
does not have access to a signer.
IdentityStrategy::ExternalIdentity allows you to provide an already-constructed identity to the
client. This is useful for testing and not expected to be used in production.
Variants§
CreateIfNotFound
Tries to get an identity from the disk store. If not found, getting one from backend.
CreateForIdentifier
CreateIfNotFound for the inbox the backend associates with the
identifier, or else the inbox its registration at the nonce creates.
CachedOnly
Identity that is already in the disk store
Implementations§
Source§impl IdentityStrategy
impl IdentityStrategy
pub fn inbox_id(&self) -> Option<&str>
Sourcepub fn new(
inbox_id: String,
identifier: Identifier,
nonce: u64,
) -> IdentityStrategy
pub fn new( inbox_id: String, identifier: Identifier, nonce: u64, ) -> IdentityStrategy
Create a new Identity Strategy, with IdentityStrategy::CreateIfNotFound.
If an Identity is not found in the local store, creates a new one.
Sourcepub fn for_identifier(identifier: Identifier, nonce: u64) -> IdentityStrategy
pub fn for_identifier(identifier: Identifier, nonce: u64) -> IdentityStrategy
Create an IdentityStrategy::CreateForIdentifier, for a caller that
does not know the identifier’s inbox. The build takes the inbox the
backend names, or the one the identifier creates at nonce, and fails
with IdentityError::IdentifierNotInInbox unless the identifier
belongs to it, as
xmtp_mls::builder::ClientBuilder::build
describes. An offline build checks the newest state the database
stores, which can predate a revocation.
Sourcepub async fn with_inbox<ApiClient>(
self,
api_client: &ApiClientWrapper<ApiClient>,
) -> Result<IdentityStrategy, IdentityError>where
ApiClient: XmtpApi,
pub async fn with_inbox<ApiClient>(
self,
api_client: &ApiClientWrapper<ApiClient>,
) -> Result<IdentityStrategy, IdentityError>where
ApiClient: XmtpApi,
Replace IdentityStrategy::CreateForIdentifier with
IdentityStrategy::CreateIfNotFound for the identifier’s inbox. Call
it only after the backend’s deployment is checked: the request carries
the identifier.
Source§impl IdentityStrategy
impl IdentityStrategy
Sourcepub async fn initialize_identity<ApiClient, S>(
self,
api_client: &ApiClientWrapper<ApiClient>,
mls_storage: &S,
scw_signature_verifier: impl SmartContractSignatureVerifier,
) -> Result<Identity, IdentityError>where
ApiClient: XmtpApi,
S: XmtpMlsStorageProvider,
pub async fn initialize_identity<ApiClient, S>(
self,
api_client: &ApiClientWrapper<ApiClient>,
mls_storage: &S,
scw_signature_verifier: impl SmartContractSignatureVerifier,
) -> Result<Identity, IdentityError>where
ApiClient: XmtpApi,
S: XmtpMlsStorageProvider,
- Initialize an identity from the given strategy. If a stored identity is found in the database,
- it will return that identity.
- If a stored identity is found, it will validate that the inbox_id of the stored identity matches
- the inbox_id configured on the strategy.
Trait Implementations§
Source§impl Clone for IdentityStrategy
impl Clone for IdentityStrategy
Source§fn clone(&self) -> IdentityStrategy
fn clone(&self) -> IdentityStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for IdentityStrategy
impl RefUnwindSafe for IdentityStrategy
impl Send for IdentityStrategy
impl Sync for IdentityStrategy
impl Unpin for IdentityStrategy
impl UnsafeUnpin for IdentityStrategy
impl UnwindSafe for IdentityStrategy
Blanket Implementations§
§impl<T> AggregateExpressionMethods for T
impl<T> AggregateExpressionMethods for T
§fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
fn aggregate_distinct(self) -> Self::Outputwhere
Self: DistinctDsl,
DISTINCT modifier for aggregate functions Read more§fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
fn aggregate_all(self) -> Self::Outputwhere
Self: AllDsl,
ALL modifier for aggregate functions Read more§fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
fn aggregate_filter<P>(self, f: P) -> Self::Outputwhere
P: AsExpression<Bool>,
Self: FilterDsl<<P as AsExpression<Bool>>::Expression>,
§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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> IntoSql for T
impl<T> IntoSql for T
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].