EAPI=8

CRATES="
	why2@1.5.0
	adler2@2.0.1
	aho-corasick@1.1.4
	alloca@0.4.0
	alsa@0.11.0
	alsa-sys@0.4.0
	anes@0.1.6
	anstyle@1.0.14
	anyhow@1.0.102
	anymap3@1.0.1
	argon2@0.5.3
	array-init@2.1.0
	audiopus@0.2.0
	audiopus_sys@0.1.8
	autocfg@1.5.0
	base16ct@0.2.0
	base64@0.22.1
	base64ct@1.8.3
	bitflags@2.11.1
	blake2@0.10.6
	block2@0.6.2
	block-buffer@0.10.4
	block-buffer@0.12.0
	bumpalo@3.20.2
	bytemuck@1.25.0
	byteorder@1.5.0
	bytes@1.11.1
	cast@0.3.0
	cc@1.2.62
	cesu8@1.1.0
	cfg_aliases@0.2.1
	cfg-if@1.0.4
	chacha20@0.10.0
	ciborium@0.2.2
	ciborium-io@0.2.2
	ciborium-ll@0.2.2
	clap@4.6.1
	clap_builder@4.6.0
	clap_lex@1.1.0
	cmov@0.5.3
	colored@3.1.1
	combine@4.6.7
	const-oid@0.10.2
	const-oid@0.9.6
	convert_case@0.10.0
	coreaudio-rs@0.14.2
	cpal@0.17.3
	cpufeatures@0.2.17
	cpufeatures@0.3.0
	crc32fast@1.5.0
	criterion@0.8.2
	criterion-plot@0.8.2
	crossbeam-deque@0.8.6
	crossbeam-epoch@0.9.18
	crossbeam-utils@0.8.21
	crossterm@0.29.0
	crossterm_winapi@0.9.1
	crunchy@0.2.4
	crypto-bigint@0.5.5
	crypto-common@0.1.6
	crypto-common@0.2.2
	ctrlc@3.5.2
	ctutils@0.4.2
	darling@0.21.3
	darling_core@0.21.3
	darling_macro@0.21.3
	dashmap@6.2.1
	dasp_sample@0.11.0
	der@0.7.10
	der@0.8.0
	deranged@0.5.8
	derive_more@2.1.1
	derive_more-impl@2.1.1
	digest@0.10.7
	digest@0.11.3
	dirs@6.0.0
	dirs-sys@0.5.0
	dispatch2@0.3.1
	document-features@0.2.12
	easyfft@0.4.2
	ecdsa@0.16.9
	either@1.15.0
	elliptic-curve@0.13.8
	equivalent@1.0.2
	errno@0.3.14
	fastrand@2.4.1
	ff@0.13.1
	filedescriptor@0.8.3
	find-msvc-tools@0.1.9
	flate2@1.1.9
	fnv@1.0.7
	foldhash@0.1.5
	futures-core@0.3.32
	futures-task@0.3.32
	futures-util@0.3.32
	gag@1.0.0
	generic-array@0.14.9
	generic_singleton@0.5.3
	getrandom@0.2.17
	getrandom@0.4.2
	group@0.13.0
	half@2.7.1
	hashbrown@0.14.5
	hashbrown@0.15.5
	hashbrown@0.17.1
	heck@0.5.0
	hkdf@0.12.4
	hkdf@0.13.0
	hmac@0.12.1
	hmac@0.13.0
	http@1.4.0
	httparse@1.10.1
	hybrid-array@0.4.12
	id-arena@2.3.0
	ident_case@1.0.1
	indexmap@2.14.0
	itertools@0.13.0
	itoa@1.0.18
	jni@0.21.1
	jni-sys@0.3.1
	jni-sys@0.4.1
	jni-sys-macros@0.4.1
	js-sys@0.3.98
	keccak@0.2.0
	kem@0.3.0
	leb128fmt@0.1.0
	lewton@0.10.2
	libc@0.2.186
	libredox@0.1.16
	linux-raw-sys@0.12.1
	litrs@1.0.0
	lock_api@0.4.14
	log@0.4.29
	mach2@0.5.0
	memchr@2.8.0
	miniz_oxide@0.8.9
	mio@1.2.0
	ml-kem@0.3.2
	module-lattice@0.2.3
	ndk@0.9.0
	ndk-context@0.1.1
	ndk-sys@0.6.0+11769913
	nix@0.31.3
	nnnoiseless@0.5.2
	num-complex@0.4.6
	num-conv@0.2.2
	num-derive@0.4.2
	num_enum@0.7.6
	num_enum_derive@0.7.6
	num-integer@0.1.46
	num_threads@0.1.7
	num-traits@0.2.19
	objc2@0.6.4
	objc2-audio-toolbox@0.3.2
	objc2-avf-audio@0.3.2
	objc2-core-audio@0.3.2
	objc2-core-audio-types@0.3.2
	objc2-core-foundation@0.3.2
	objc2-encode@4.1.0
	objc2-foundation@0.3.2
	ogg@0.8.0
	once_cell@1.21.4
	oorandom@11.1.5
	option-ext@0.2.0
	p521@0.13.3
	page_size@0.6.0
	parking_lot@0.12.5
	parking_lot_core@0.9.12
	password-hash@0.5.0
	pastey@0.2.3
	pem-rfc7468@0.7.0
	percent-encoding@2.3.2
	pin-project-lite@0.2.17
	pkcs8@0.10.2
	pkcs8@0.11.0
	pkg-config@0.3.33
	plotters@0.3.7
	plotters-backend@0.3.7
	plotters-svg@0.3.7
	portable-atomic@1.13.1
	portable-atomic-util@0.2.7
	powerfmt@0.2.0
	ppv-lite86@0.2.21
	prettyplease@0.2.37
	primal-check@0.3.4
	primeorder@0.13.6
	proc-macro2@1.0.106
	proc-macro-crate@3.5.0
	quote@1.0.45
	rand@0.10.1
	rand_chacha@0.10.0
	rand_core@0.10.1
	rand_core@0.6.4
	rayon@1.12.0
	rayon-core@1.13.0
	realfft@3.5.0
	redox_syscall@0.5.18
	redox_users@0.5.2
	r-efi@6.0.0
	regex@1.12.3
	regex-automata@0.4.14
	regex-syntax@0.8.10
	rfc6979@0.4.0
	ring@0.17.14
	ringbuf@0.5.0
	rustc_version@0.4.1
	rustfft@6.4.1
	rustix@1.1.4
	rustls@0.23.40
	rustls-pki-types@1.14.1
	rustls-webpki@0.103.13
	rustversion@1.0.22
	safe_arch@1.0.0
	same-file@1.0.6
	scopeguard@1.2.0
	sec1@0.7.3
	semver@1.0.28
	serde@1.0.228
	serde_core@1.0.228
	serde_derive@1.0.228
	serde_json@1.0.149
	sha2@0.10.9
	sha2@0.11.0
	sha3@0.11.0
	shlex@1.3.0
	signal-hook@0.3.18
	signal-hook-mio@0.2.5
	signal-hook-registry@1.4.8
	signature@2.2.0
	simd-adler32@0.3.9
	simple_logger@5.2.0
	slab@0.4.12
	smallvec@1.15.1
	socks@0.3.4
	spki@0.7.3
	spki@0.8.0
	strength_reduce@0.2.4
	strsim@0.11.1
	subtle@2.6.1
	syn@2.0.117
	tempfile@3.27.0
	thiserror@1.0.69
	thiserror@2.0.18
	thiserror-impl@1.0.69
	thiserror-impl@2.0.18
	time@0.3.47
	time-core@0.1.8
	time-macros@0.2.27
	tinytemplate@1.2.1
	tinyvec@1.11.0
	tinyvec_macros@0.1.1
	toml_datetime@1.1.1+spec-1.1.0
	toml_edit@0.25.11+spec-1.1.0
	toml_parser@1.1.2+spec-1.1.0
	toml_writer@1.1.1+spec-1.1.0
	transpose@0.2.3
	typenum@1.20.0
	unicode-ident@1.0.24
	unicode-segmentation@1.13.2
	unicode-xid@0.2.6
	untrusted@0.9.0
	ureq@3.3.0
	ureq-proto@0.6.0
	utf8-zero@0.8.1
	version_check@0.9.5
	walkdir@2.5.0
	wasi@0.11.1+wasi-snapshot-preview1
	wasip2@1.0.3+wasi-0.2.9
	wasip3@0.4.0+wasi-0.3.0-rc-2026-01-06
	wasm-bindgen@0.2.121
	wasm-bindgen-futures@0.4.71
	wasm-bindgen-macro@0.2.121
	wasm-bindgen-macro-support@0.2.121
	wasm-bindgen-shared@0.2.121
	wasm-encoder@0.244.0
	wasm-metadata@0.244.0
	wasmparser@0.244.0
	webpki-roots@1.0.7
	web-sys@0.3.98
	wide@1.4.0
	winapi@0.3.9
	winapi-i686-pc-windows-gnu@0.4.0
	winapi-util@0.1.11
	winapi-x86_64-pc-windows-gnu@0.4.0
	wincode@0.5.4
	wincode-derive@0.4.5
	windows@0.62.2
	windows_aarch64_gnullvm@0.42.2
	windows_aarch64_gnullvm@0.52.6
	windows_aarch64_msvc@0.42.2
	windows_aarch64_msvc@0.52.6
	windows-collections@0.3.2
	windows-core@0.62.2
	windows-future@0.3.2
	windows_i686_gnu@0.42.2
	windows_i686_gnu@0.52.6
	windows_i686_gnullvm@0.52.6
	windows_i686_msvc@0.42.2
	windows_i686_msvc@0.52.6
	windows-implement@0.60.2
	windows-interface@0.59.3
	windows-link@0.2.1
	windows-numerics@0.3.1
	windows-result@0.4.1
	windows-strings@0.5.1
	windows-sys@0.45.0
	windows-sys@0.52.0
	windows-sys@0.61.2
	windows-targets@0.42.2
	windows-targets@0.52.6
	windows-threading@0.2.1
	windows_x86_64_gnu@0.42.2
	windows_x86_64_gnu@0.52.6
	windows_x86_64_gnullvm@0.42.2
	windows_x86_64_gnullvm@0.52.6
	windows_x86_64_msvc@0.42.2
	windows_x86_64_msvc@0.52.6
	winnow@1.0.3
	wit-bindgen@0.51.0
	wit-bindgen@0.57.1
	wit-bindgen-core@0.51.0
	wit-bindgen-rust@0.51.0
	wit-bindgen-rust-macro@0.51.0
	wit-component@0.244.0
	wit-parser@0.244.0
	zerocopy@0.8.48
	zerocopy-derive@0.8.48
	zeroize@1.8.2
	zeroize_derive@1.4.3
	zmij@1.0.21
"

inherit cargo

DESCRIPTION="Lightweight, fast and secure chat application powered by WHY2 encryption."
HOMEPAGE="https://why2.satan.red"

MY_PN="why2-chat"
SRC_URI="https://crates.io/api/v1/crates/${MY_PN}/${PV}/download -> ${MY_PN}-${PV}.crate ${CARGO_CRATE_URIS}"
S="${WORKDIR}/${MY_PN}-${PV}"

LICENSE="GPL-3 0BSD Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD BSD-2 BlueOak-1.0.0 CDLA-Permissive-2.0 ISC LGPL-2.1+ MIT MPL-2.0 Unicode-3.0 Unlicense ZLIB"
SLOT="0"
KEYWORDS="~amd64"

QA_FLAGS_IGNORED="usr/bin/why2 usr/bin/why2-server"
IUSE="+server"

DEPEND="media-libs/alsa-lib"
RDEPEND="${DEPEND}"
BDEPEND="virtual/pkgconfig"

src_unpack() {
	cargo_src_unpack
	tar xf "${DISTDIR}/${MY_PN}-${PV}.crate" -C "${WORKDIR}" || die
}

src_compile() {
	cargo_src_compile  # builds client (default features)
	if use server; then
	cargo_src_compile --bin why2-server --no-default-features --features server
	fi
}

src_install() {
	dobin "$(cargo_target_dir)/why2"
	use server && dobin "$(cargo_target_dir)/why2-server"
}
