/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::{collections::BTreeMap, hash::Hasher}; pubuse uniffi_checksum_derive::Checksum;
mod ffi_names; pubuse ffi_names::*;
mod group; pubuse group::{create_metadata_groups, fixup_external_type, group_metadata, MetadataGroup};
mod reader; pubuse reader::{read_metadata, read_metadata_type};
mod types; pubuse types::{AsType, ExternalKind, ObjectImpl, Type, TypeIterator};
mod metadata;
// This needs to match the minor version of the `uniffi` crate. See // `docs/uniffi-versioning.md` for details. // // Once we get to 1.0, then we'll need to update the scheme to something like 100 + major_version pubconst UNIFFI_CONTRACT_VERSION: u32 = 26;
/// Similar to std::hash::Hash. /// /// Implementations of this trait are expected to update the hasher state in /// the same way across platforms. #[derive(Checksum)] will do the right thing. pubtrait Checksum { fn checksum<H: Hasher>(&self, state: &mut H);
}
// The namespace of a Component interface. // // This is used to match up the macro metadata with the UDL items. #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] pubstruct NamespaceMetadata { pub crate_name: String, pub name: String,
}
// UDL file included with `include_scaffolding!()` // // This is to find the UDL files in library mode generation #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pubstruct UdlFile { // The module path specified when the UDL file was parsed. pub module_path: String, pub namespace: String, // the base filename of the udl file - no path, no extension. pub file_stub: String,
}
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Checksum)] pubenum LiteralMetadata {
Boolean(bool),
String(String), // Integers are represented as the widest representation we can. // Number formatting vary with language and radix, so we avoid a lot of parsing and // formatting duplication by using only signed and unsigned variants.
UInt(u64, Radix, Type),
Int(i64, Radix, Type), // Pass the string representation through as typed in the UDL. // This avoids a lot of uncertainty around precision and accuracy, // though bindings for languages less sophisticated number parsing than WebIDL // will have to do extra work.
Float(String, Type), Enum(String, Type),
EmptySequence,
EmptyMap,
None,
Some { inner: Box<LiteralMetadata> },
}
impl ObjectMetadata { /// FFI symbol name for the `clone` function for this object. /// /// This function is used to increment the reference count before lowering an object to pass /// back to Rust. pubfn clone_ffi_symbol_name(&self) -> String {
clone_fn_symbol_name(&self.module_path, &self.name)
}
/// FFI symbol name for the `free` function for this object. /// /// This function is used to free the memory used by this object. pubfn free_ffi_symbol_name(&self) -> String {
free_fn_symbol_name(&self.module_path, &self.name)
}
}
/// The list of traits we support generating helper methods for. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pubenum UniffiTraitMetadata {
Debug {
fmt: MethodMetadata,
},
Display {
fmt: MethodMetadata,
},
Eq {
eq: MethodMetadata,
ne: MethodMetadata,
},
Hash {
hash: MethodMetadata,
},
}
/// Returns the last 16 bits of the value's hash as computed with [`SipHasher13`]. /// /// This is used as a safeguard against different UniFFI versions being used for scaffolding and /// bindings generation. pubfn checksum<T: Checksum>(val: &T) -> u16 { letmut hasher = siphasher::sip::SipHasher13::new();
val.checksum(&mut hasher);
(hasher.finish() & 0x000000000000FFFF) as u16
}
/// Enum covering all the possible metadata types #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord)] pubenum Metadata {
Namespace(NamespaceMetadata),
UdlFile(UdlFile),
Func(FnMetadata),
Object(ObjectMetadata),
CallbackInterface(CallbackInterfaceMetadata),
Record(RecordMetadata), Enum(EnumMetadata),
Constructor(ConstructorMetadata),
Method(MethodMetadata),
TraitMethod(TraitMethodMetadata),
CustomType(CustomTypeMetadata),
UniffiTrait(UniffiTraitMetadata),
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.