Compare commits
20 Commits
f96a642cf0
...
6ee7887bd2
Author | SHA1 | Date |
---|---|---|
Savanni D'Gerinel | 6ee7887bd2 | |
Savanni D'Gerinel | a584329d78 | |
Savanni D'Gerinel | 902b690d1a | |
Savanni D'Gerinel | c030b2d941 | |
Savanni D'Gerinel | 130b9f6c32 | |
Savanni D'Gerinel | 3f6f8c453b | |
Savanni D'Gerinel | f0ead7d422 | |
Savanni D'Gerinel | 4f01e1306e | |
Savanni D'Gerinel | ae22d2191c | |
Savanni D'Gerinel | 522f7eb65b | |
Savanni D'Gerinel | d601c8feeb | |
Savanni D'Gerinel | dfd755ed0a | |
Savanni D'Gerinel | 1f8a0215dc | |
Savanni D'Gerinel | 2857982b82 | |
Savanni D'Gerinel | d7108d0355 | |
Savanni D'Gerinel | cca1b9c3ba | |
Savanni D'Gerinel | a8d8210252 | |
Savanni D'Gerinel | 214463f6b4 | |
Savanni D'Gerinel | 411e0261fc | |
Savanni D'Gerinel | 12e9067c14 |
|
@ -1,2 +1,4 @@
|
|||
target
|
||||
.direnv/
|
||||
node_modules
|
||||
dist
|
||||
|
|
|
@ -0,0 +1,674 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
|
@ -2,6 +2,8 @@
|
|||
name = "changeset"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-only"
|
||||
license-file = "../COPYING"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use std::{
|
||||
collections::{HashMap, HashSet},
|
||||
hash::Hash,
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
name = "coordinates"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-only"
|
||||
license-file = "../COPYING"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use coordinates::hex_map;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2022-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// Ĉi-tiu modulo enhavas la elementojn por kub-koordinato.
|
||||
///
|
||||
/// This code is based on https://www.redblobgames.com/grids/hexagons/
|
||||
|
|
|
@ -3,7 +3,8 @@ name = "emseries"
|
|||
version = "0.5.1"
|
||||
authors = ["Savanni D'Gerinel <savanni@luminescent-dreams.com>"]
|
||||
description = "an Embedded Time Series database"
|
||||
license = "BSD-3-Clause"
|
||||
license = "GPL-3.0-only"
|
||||
license-file = "../COPYING"
|
||||
documentation = "https://docs.rs/emseries"
|
||||
homepage = "https://github.com/luminescent-dreams/emseries"
|
||||
repository = "https://github.com/luminescent-dreams/emseries"
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use date_time_tz::DateTimeTz;
|
||||
use types::Recordable;
|
||||
|
||||
|
@ -8,14 +20,12 @@ pub trait Criteria {
|
|||
fn apply<T: Recordable>(&self, record: &T) -> bool;
|
||||
}
|
||||
|
||||
|
||||
/// Specify two criteria that must both be matched.
|
||||
pub struct And<A: Criteria, B: Criteria> {
|
||||
pub lside: A,
|
||||
pub rside: B,
|
||||
}
|
||||
|
||||
|
||||
impl<A, B> Criteria for And<A, B>
|
||||
where
|
||||
A: Criteria,
|
||||
|
@ -26,14 +36,12 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Specify two criteria, either of which may be matched.
|
||||
pub struct Or<A: Criteria, B: Criteria> {
|
||||
pub lside: A,
|
||||
pub rside: B,
|
||||
}
|
||||
|
||||
|
||||
/// Specify the starting time for a search. This consists of a UTC timestamp and a specifier as to
|
||||
/// whether the exact time is included in the search criteria.
|
||||
pub struct StartTime {
|
||||
|
@ -41,7 +49,6 @@ pub struct StartTime {
|
|||
pub incl: bool,
|
||||
}
|
||||
|
||||
|
||||
impl Criteria for StartTime {
|
||||
fn apply<T: Recordable>(&self, record: &T) -> bool {
|
||||
if self.incl {
|
||||
|
@ -52,7 +59,6 @@ impl Criteria for StartTime {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Specify the ending time for a search. This consists of a UTC timestamp and a specifier as to
|
||||
/// whether the exact time is included in the search criteria.
|
||||
pub struct EndTime {
|
||||
|
@ -60,7 +66,6 @@ pub struct EndTime {
|
|||
pub incl: bool,
|
||||
}
|
||||
|
||||
|
||||
impl Criteria for EndTime {
|
||||
fn apply<T: Recordable>(&self, record: &T) -> bool {
|
||||
if self.incl {
|
||||
|
@ -71,7 +76,6 @@ impl Criteria for EndTime {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Specify a list of tags that must exist on the record.
|
||||
pub struct Tags {
|
||||
pub tags: Vec<String>,
|
||||
|
@ -80,13 +84,10 @@ pub struct Tags {
|
|||
impl Criteria for Tags {
|
||||
fn apply<T: Recordable>(&self, record: &T) -> bool {
|
||||
let record_tags = record.tags();
|
||||
self.tags
|
||||
.iter()
|
||||
.all(|v| record_tags.contains(v))
|
||||
self.tags.iter().all(|v| record_tags.contains(v))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Specify a criteria that searches for records matching an exact time.
|
||||
pub fn exact_time(time: DateTimeTz) -> And<StartTime, EndTime> {
|
||||
And {
|
||||
|
@ -98,7 +99,6 @@ pub fn exact_time(time: DateTimeTz) -> And<StartTime, EndTime> {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// Specify a criteria that searches for all records within a time range.
|
||||
pub fn time_range(
|
||||
start: DateTimeTz,
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern crate chrono;
|
||||
extern crate chrono_tz;
|
||||
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// NOTE: this module is a candidate for extraction into its own crate, or should be replaced with
|
||||
// an existing crate.
|
||||
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*! An Embedded Time Series Database
|
||||
|
||||
This library provides a low-intensity time series database meant to be embedded inside of an
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern crate serde;
|
||||
extern crate serde_json;
|
||||
extern crate uuid;
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use date_time_tz::DateTimeTz;
|
||||
use serde::de::DeserializeOwned;
|
||||
use serde::ser::Serialize;
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#[macro_use]
|
||||
extern crate serde_derive;
|
||||
|
||||
|
|
28
flake.lock
28
flake.lock
|
@ -17,16 +17,16 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1672580127,
|
||||
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||
"lastModified": 1675918889,
|
||||
"narHash": "sha256-hy7re4F9AEQqwZxubct7jBRos6md26bmxnCjxf5utJA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||
"rev": "49efda9011e8cdcd6c1aad30384cb1dc230c82fe",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-22.05",
|
||||
"ref": "nixos-22.11",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
|
@ -52,7 +52,7 @@
|
|||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"narHash": "sha256-/YOtiDKPUXKKpIhsAds11llfC42ScGW27bbHnNZebco=",
|
||||
"narHash": "sha256-0eO3S+2gLODqDoloufeC99PfQ5mthuN9JADzqFXid1Y=",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"
|
||||
},
|
||||
|
@ -64,7 +64,23 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"oxalica": "oxalica"
|
||||
"oxalica": "oxalica",
|
||||
"unstable": "unstable"
|
||||
}
|
||||
},
|
||||
"unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1675942811,
|
||||
"narHash": "sha256-/v4Z9mJmADTpXrdIlAjFa1e+gkpIIROR670UVDQFwIw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "724bfc0892363087709bd3a5a1666296759154b1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"ref": "nixos-unstable",
|
||||
"type": "indirect"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
22
flake.nix
22
flake.nix
|
@ -2,11 +2,12 @@
|
|||
description = "Lumenescent Dreams Tools";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "nixpkgs/nixos-22.05";
|
||||
nixpkgs.url = "nixpkgs/nixos-22.11";
|
||||
unstable.url = "nixpkgs/nixos-unstable";
|
||||
oxalica.url = "https://github.com/oxalica/rust-overlay/archive/master.tar.gz";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, oxalica }:
|
||||
outputs = { self, nixpkgs, unstable, oxalica }:
|
||||
let
|
||||
version = builtins.string 0 8 self.lastModifiedDate;
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
|
@ -16,6 +17,7 @@
|
|||
let
|
||||
rust_overlay = import oxalica;
|
||||
pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ rust_overlay ]; };
|
||||
pkgs-unstable = import unstable { system = "x86_64-linux"; overlays = [ rust_overlay ]; };
|
||||
rust = pkgs.rust-bin.stable."1.65.0".default.override {
|
||||
extensions = [ "rust-src" ];
|
||||
};
|
||||
|
@ -23,10 +25,24 @@
|
|||
pkgs.mkShell {
|
||||
name = "ld-tools-devshell";
|
||||
buildInputs = [
|
||||
pkgs.pkg-config
|
||||
pkgs.clang
|
||||
pkgs.entr
|
||||
pkgs.glade
|
||||
pkgs.glib
|
||||
pkgs.gst_all_1.gst-plugins-bad
|
||||
pkgs.gst_all_1.gst-plugins-base
|
||||
pkgs.gst_all_1.gst-plugins-good
|
||||
pkgs.gst_all_1.gst-plugins-ugly
|
||||
pkgs.gst_all_1.gstreamer
|
||||
pkgs.gtk4
|
||||
pkgs.nodejs
|
||||
pkgs.openssl
|
||||
pkgs.pipewire
|
||||
pkgs.pkg-config
|
||||
pkgs.sqlite
|
||||
rust
|
||||
];
|
||||
LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "flow"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "flow"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
|
||||
[dev-dependencies]
|
||||
thiserror = "1"
|
|
@ -0,0 +1,3 @@
|
|||
# Flow
|
||||
|
||||
This is a library to help with application control flow, separating fatal errors from normal recoverable errors. This is almost entirely inspired by [Error Handling in a Correctness-Critical Rust Project](https://sled.rs/errors.html) in the sled.rs library.
|
|
@ -0,0 +1,257 @@
|
|||
//! Control Flow for Correctness-Critical applications
|
||||
//!
|
||||
//! https://sled.rs/errors.html
|
||||
//!
|
||||
//! Where the sled.rs library uses `Result<Result<A, Error>, FatalError>`, these are a little hard to
|
||||
//! work with. This library works out a set of utility functions that allow us to work with the
|
||||
//! nested errors in the same way as a regular Result.
|
||||
use std::error::Error;
|
||||
|
||||
/// Implement this trait for the application's fatal errors.
|
||||
///
|
||||
/// Fatal errors should be things that should trigger an application shutdown. Applications should
|
||||
/// not try to recover from fatal errors, but simply bring the app to the safest shutdown point and
|
||||
/// report the best possible information to the user.
|
||||
///
|
||||
/// Examples: database corruption, or the database is unavailable in an application that cannot
|
||||
/// function without it. Graphics environment cannot be initialized in a GUI app.
|
||||
///
|
||||
/// Applications should generally have only one FatalError type. There are no handling utilities
|
||||
/// for Fatal conditions, so Fatal conditions must be handled through an ordinary `match`
|
||||
/// statement.
|
||||
pub trait FatalError: Error {}
|
||||
|
||||
/// Flow<A, FE, E> represents a return value that might be a success, might be a fatal error, or
|
||||
/// might be a normal handleable error.
|
||||
pub enum Flow<A, FE, E> {
|
||||
/// The operation was successful
|
||||
Ok(A),
|
||||
/// The operation encountered a fatal error. These should be bubbled up to a level that can
|
||||
/// safely shut the application down.
|
||||
Fatal(FE),
|
||||
/// Ordinary errors. These should be handled and the application should recover gracefully.
|
||||
Err(E),
|
||||
}
|
||||
|
||||
impl<A, FE, E> Flow<A, FE, E> {
|
||||
/// Apply an infallible function to a successful value.
|
||||
pub fn map<B, O>(self, mapper: O) -> Flow<B, FE, E>
|
||||
where
|
||||
O: FnOnce(A) -> B,
|
||||
{
|
||||
match self {
|
||||
Flow::Ok(val) => Flow::Ok(mapper(val)),
|
||||
Flow::Fatal(err) => Flow::Fatal(err),
|
||||
Flow::Err(err) => Flow::Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a potentially fallible function to a successful value.
|
||||
///
|
||||
/// Like `Result.and_then`, the mapping function can itself fail.
|
||||
pub fn and_then<B, O>(self, handler: O) -> Flow<B, FE, E>
|
||||
where
|
||||
O: FnOnce(A) -> Flow<B, FE, E>,
|
||||
{
|
||||
match self {
|
||||
Flow::Ok(val) => handler(val),
|
||||
Flow::Fatal(err) => Flow::Fatal(err),
|
||||
Flow::Err(err) => Flow::Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
/// Map a normal error from one type to another. This is useful for converting an error from
|
||||
/// one type to another, especially in re-throwing an underlying error. `?` syntax does not
|
||||
/// work with `Flow`, so you will likely need to use this a lot.
|
||||
pub fn map_err<F, O>(self, mapper: O) -> Flow<A, FE, F>
|
||||
where
|
||||
O: FnOnce(E) -> F,
|
||||
{
|
||||
match self {
|
||||
Flow::Ok(val) => Flow::Ok(val),
|
||||
Flow::Fatal(err) => Flow::Fatal(err),
|
||||
Flow::Err(err) => Flow::Err(mapper(err)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Provide a function to use to recover from (or simply re-throw) an error.
|
||||
pub fn or_else<O, F>(self, handler: O) -> Flow<A, FE, F>
|
||||
where
|
||||
O: FnOnce(E) -> Flow<A, FE, F>,
|
||||
{
|
||||
match self {
|
||||
Flow::Ok(val) => Flow::Ok(val),
|
||||
Flow::Fatal(err) => Flow::Fatal(err),
|
||||
Flow::Err(err) => handler(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert from a normal `Result` type to a `Flow` type. The error condition for a `Result` will
|
||||
/// be treated as `Flow::Err`, never `Flow::Fatal`.
|
||||
impl<A, FE, E> From<Result<A, E>> for Flow<A, FE, E> {
|
||||
fn from(r: Result<A, E>) -> Self {
|
||||
match r {
|
||||
Ok(val) => Flow::Ok(val),
|
||||
Err(err) => Flow::Err(err),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Convenience function to create an ok value.
|
||||
pub fn ok<A, FE: FatalError, E: Error>(val: A) -> Flow<A, FE, E> {
|
||||
Flow::Ok(val)
|
||||
}
|
||||
|
||||
/// Convenience function to create an error value.
|
||||
pub fn error<A, FE: FatalError, E: Error>(err: E) -> Flow<A, FE, E> {
|
||||
Flow::Err(err)
|
||||
}
|
||||
|
||||
/// Convenience function to create a fatal value.
|
||||
pub fn fatal<A, FE: FatalError, E: Error>(err: FE) -> Flow<A, FE, E> {
|
||||
Flow::Fatal(err)
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
/// Return early from the current function if the value is a fatal error.
|
||||
macro_rules! return_fatal {
|
||||
($x:expr) => {
|
||||
match $x {
|
||||
Flow::Fatal(err) => return Flow::Fatal(err),
|
||||
Flow::Err(err) => Err(err),
|
||||
Flow::Ok(val) => Ok(val),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
/// Return early from the current function is the value is an error.
|
||||
macro_rules! return_error {
|
||||
($x:expr) => {
|
||||
match $x {
|
||||
Flow::Ok(val) => val,
|
||||
Flow::Err(err) => return Flow::Err(err),
|
||||
Flow::Fatal(err) => return Flow::Fatal(err),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
enum FatalError {
|
||||
#[error("A fatal error occurred")]
|
||||
FatalError,
|
||||
}
|
||||
impl super::FatalError for FatalError {}
|
||||
impl PartialEq for FatalError {
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
enum Error {
|
||||
#[error("an error occurred")]
|
||||
Error,
|
||||
}
|
||||
impl PartialEq for Error {
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl PartialEq for Flow<i32, FatalError, Error> {
|
||||
fn eq(&self, rhs: &Self) -> bool {
|
||||
match (self, rhs) {
|
||||
(Flow::Ok(val), Flow::Ok(rhs)) => val == rhs,
|
||||
(Flow::Err(_), Flow::Err(_)) => true,
|
||||
(Flow::Fatal(_), Flow::Fatal(_)) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Flow<i32, FatalError, Error> {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Flow::Ok(val) => f.write_fmt(format_args!("Flow::Ok {}", val)),
|
||||
Flow::Err(err) => f.write_fmt(format_args!("Flow::Err {:?}", err)),
|
||||
Flow::Fatal(err) => f.write_fmt(format_args!("Flow::Fatal {:?}", err)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_can_map_things() {
|
||||
let success = ok(15);
|
||||
assert_eq!(ok(16), success.map(|v| v + 1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_can_chain_success() {
|
||||
let success = ok(15);
|
||||
assert_eq!(ok(16), success.and_then(|v| ok(v + 1)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_can_handle_an_error() {
|
||||
let failure = error(Error::Error);
|
||||
assert_eq!(ok(16), failure.or_else(|_| ok(16)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn early_exit_on_fatal() {
|
||||
fn ok_func() -> Flow<i32, FatalError, Error> {
|
||||
let value = return_fatal!(ok::<i32, FatalError, Error>(15));
|
||||
match value {
|
||||
Ok(_) => ok(14),
|
||||
Err(err) => error(err),
|
||||
}
|
||||
}
|
||||
|
||||
fn err_func() -> Flow<i32, FatalError, Error> {
|
||||
let value = return_fatal!(error::<i32, FatalError, Error>(Error::Error));
|
||||
match value {
|
||||
Ok(_) => panic!("shouldn't have gotten here"),
|
||||
Err(err) => ok(0),
|
||||
}
|
||||
}
|
||||
|
||||
fn fatal_func() -> Flow<i32, FatalError, Error> {
|
||||
return_fatal!(fatal::<i32, FatalError, Error>(FatalError::FatalError));
|
||||
panic!("failed to bail");
|
||||
}
|
||||
|
||||
fatal_func();
|
||||
assert_eq!(ok_func(), ok(14));
|
||||
assert_eq!(err_func(), ok(0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn it_can_early_exit_on_all_errors() {
|
||||
fn ok_func() -> Flow<i32, FatalError, Error> {
|
||||
let value = return_error!(ok::<i32, FatalError, Error>(15));
|
||||
assert_eq!(value, 15);
|
||||
ok(14)
|
||||
}
|
||||
|
||||
fn err_func() -> Flow<i32, FatalError, Error> {
|
||||
return_error!(error::<i32, FatalError, Error>(Error::Error));
|
||||
panic!("failed to bail");
|
||||
}
|
||||
|
||||
fn fatal_func() -> Flow<i32, FatalError, Error> {
|
||||
return_error!(fatal::<i32, FatalError, Error>(FatalError::FatalError));
|
||||
panic!("failed to bail");
|
||||
}
|
||||
|
||||
fatal_func();
|
||||
assert_eq!(ok_func(), ok(14));
|
||||
err_func();
|
||||
}
|
||||
}
|
|
@ -4,7 +4,8 @@ authors = ["Savanni D'Gerinel <savanni@luminescent-dreams.com>"]
|
|||
edition = "2018"
|
||||
version = "0.2.0"
|
||||
description = "An ergonomics wrapper around Fluent-RS"
|
||||
license = "AGPL-3.0-or-later"
|
||||
license = "GPL-3.0-only"
|
||||
license-file = "../COPYING"
|
||||
homepage = "https://github.com/luminescent-dreams/fluent-ergonomics"
|
||||
repository = "https://github.com/luminescent-dreams/fluent-ergonomics"
|
||||
categories = ["internationalization"]
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
//! Provide a more ergonomic interface to the base Fluent library
|
||||
//!
|
||||
//! The Fluent class makes it easier to load translation bundles with language fallbacks and to go
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,19 @@
|
|||
[package]
|
||||
name = "hex-grid"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "GPL-3.0-only"
|
||||
license-file = "../COPYING"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
cairo-rs = "0.16"
|
||||
gio = "0.16"
|
||||
glib = "0.16"
|
||||
gtk = { version = "0.5", package = "gtk4" }
|
||||
coordinates = { path = "../coordinates" }
|
||||
image = { version = "0.24" }
|
||||
|
||||
[build-dependencies]
|
||||
glib-build-tools = "0.16"
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
glib_build_tools::compile_resources(
|
||||
"resources",
|
||||
"resources/resources.gresources.xml",
|
||||
"com.luminescent-dreams.hex-grid.gresource",
|
||||
);
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<interface>
|
||||
<template class="HexGridWindow" parent="GtkApplicationWindow">
|
||||
<property name="can-focus">False</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="drawing_area">
|
||||
<property name="width-request">1024</property>
|
||||
<property name="height-request">768</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">8</property>
|
||||
<property name="margin-end">8</property>
|
||||
<property name="margin-top">8</property>
|
||||
<property name="margin-bottom">8</property>
|
||||
<property name="hexpand">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="width-request">100</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">8</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">8</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Canvas Address</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="canvas_address">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="label" translatable="yes">-----</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="spacing">8</property>
|
||||
<property name="homogeneous">True</property>
|
||||
<child>
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="label" translatable="yes">Hexagon Address</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="hex_address">
|
||||
<property name="visible">True</property>
|
||||
<property name="can-focus">False</property>
|
||||
<property name="margin-start">4</property>
|
||||
<property name="margin-end">4</property>
|
||||
<property name="margin-top">4</property>
|
||||
<property name="margin-bottom">4</property>
|
||||
<property name="label" translatable="yes">-----</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
</interface>
|
|
@ -0,0 +1,37 @@
|
|||
[0, 0] m
|
||||
[-3, 2] sw
|
||||
[1, -2] g
|
||||
[0, 3] g
|
||||
[2, 1] g
|
||||
[0, -2] g
|
||||
[-1, 0] g
|
||||
[-2, 2] g
|
||||
[3, -3] sw
|
||||
[1, 2] g
|
||||
[1, 1] d
|
||||
[2, -2] b
|
||||
[-3, 0] sw
|
||||
[-2, 0] g
|
||||
[2, -3] sw
|
||||
[-1, -1] g
|
||||
[-2, 3] sw
|
||||
[1, -3] sw
|
||||
[-3, 3] sw
|
||||
[-1, 1] g
|
||||
[1, 0] g
|
||||
[0, 1] g
|
||||
[-1, 2] s
|
||||
[1, -1] g
|
||||
[2, -1] g
|
||||
[0, -3] sw
|
||||
[0, 2] g
|
||||
[3, 0] sw
|
||||
[-1, 3] sw
|
||||
[0, -1] g
|
||||
[3, -1] sw
|
||||
[-3, 1] sw
|
||||
[2, 0] g
|
||||
[-2, 1] g
|
||||
[3, -2] sw
|
||||
[-1, -2] sw
|
||||
[-2, -1] dw
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/com/luminescent-dreams/hex-grid/">
|
||||
<file>main.glade</file>
|
||||
<file>terrain.ppm</file>
|
||||
<file>map.txt</file>
|
||||
</gresource>
|
||||
</gresources>
|
Binary file not shown.
|
@ -0,0 +1,345 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use cairo::{Context, Path};
|
||||
use coordinates::{hex_map::parse_data, AxialAddr};
|
||||
use gio::resources_lookup_data;
|
||||
use glib::{subclass::InitializingObject, Object};
|
||||
use gtk::{
|
||||
gdk_pixbuf::Pixbuf, gio, prelude::*, subclass::prelude::*, Application, CompositeTemplate,
|
||||
DrawingArea, Label,
|
||||
};
|
||||
use image::io::Reader as ImageReader;
|
||||
use std::{cell::RefCell, io::Cursor, rc::Rc};
|
||||
|
||||
const APP_ID: &'static str = "com.luminescent-dreams.hex-grid";
|
||||
const HEX_RADIUS: f64 = 50.;
|
||||
const MAP_RADIUS: usize = 3;
|
||||
const DRAWING_ORIGIN: (f64, f64) = (1024. / 2., 768. / 2.);
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
enum Tile {
|
||||
Empty,
|
||||
Mountain,
|
||||
Grasslands,
|
||||
ShallowWater,
|
||||
DeepWater,
|
||||
Badlands,
|
||||
Desert,
|
||||
Swamp,
|
||||
}
|
||||
|
||||
impl Tile {
|
||||
fn color(&self) -> (f64, f64, f64) {
|
||||
match self {
|
||||
Self::Empty => (0., 0., 0.),
|
||||
Self::Mountain => (0.5, 0.5, 0.5),
|
||||
Self::Grasslands => (0., 1., 0.),
|
||||
Self::ShallowWater => (0.5, 0.5, 1.),
|
||||
Self::DeepWater => (0., 0., 1.),
|
||||
Self::Badlands => (0.5, 0.25, 0.),
|
||||
Self::Desert => (1., 1., 0.),
|
||||
Self::Swamp => (0., 0.25, 0.),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Tile {
|
||||
fn default() -> Self {
|
||||
Self::Empty
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&str> for Tile {
|
||||
fn from(s: &str) -> Self {
|
||||
match s {
|
||||
"m" => Self::Mountain,
|
||||
"g" => Self::Grasslands,
|
||||
"sw" => Self::ShallowWater,
|
||||
"dw" => Self::DeepWater,
|
||||
"b" => Self::Badlands,
|
||||
"d" => Self::Desert,
|
||||
"s" => Self::Swamp,
|
||||
_ => Self::Empty,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for Tile {
|
||||
fn from(s: String) -> Self {
|
||||
Self::from(s.as_ref())
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
gio::resources_register_include!("com.luminescent-dreams.hex-grid.gresource")
|
||||
.expect("Failed to register resources");
|
||||
|
||||
let app = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
app.connect_activate(|app| {
|
||||
let window = HexGridWindow::new(app);
|
||||
window.present();
|
||||
});
|
||||
|
||||
app.run();
|
||||
}
|
||||
|
||||
#[derive(CompositeTemplate, Default)]
|
||||
#[template(resource = "/com/luminescent-dreams/hex-grid/main.glade")]
|
||||
pub struct HexGridWindowPrivate {
|
||||
#[template_child]
|
||||
pub drawing_area: TemplateChild<DrawingArea>,
|
||||
#[template_child]
|
||||
pub hex_address: TemplateChild<Label>,
|
||||
#[template_child]
|
||||
pub canvas_address: TemplateChild<Label>,
|
||||
|
||||
current_coordinate: Rc<RefCell<Option<AxialAddr>>>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for HexGridWindowPrivate {
|
||||
const NAME: &'static str = "HexGridWindow";
|
||||
type Type = HexGridWindow;
|
||||
type ParentType = gtk::ApplicationWindow;
|
||||
|
||||
fn class_init(c: &mut Self::Class) {
|
||||
c.bind_template();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for HexGridWindowPrivate {
|
||||
fn constructed(&self) {
|
||||
self.parent_constructed();
|
||||
|
||||
let map_text_resource = resources_lookup_data(
|
||||
"/com/luminescent-dreams/hex-grid/map.txt",
|
||||
gio::ResourceLookupFlags::NONE,
|
||||
)
|
||||
.expect("map should be in the bundle")
|
||||
.to_vec();
|
||||
|
||||
let hex_map = parse_data::<Tile>(String::from_utf8(map_text_resource).unwrap().lines());
|
||||
|
||||
let terrain_data = resources_lookup_data(
|
||||
"/com/luminescent-dreams/hex-grid/terrain.ppm",
|
||||
gio::ResourceLookupFlags::NONE,
|
||||
)
|
||||
.unwrap();
|
||||
let reader = ImageReader::new(Cursor::new(terrain_data))
|
||||
.with_guessed_format()
|
||||
.unwrap();
|
||||
let image = reader.decode().unwrap();
|
||||
|
||||
let image_deep_water = pixbuf_from_image_tile(image.clone().crop(0, 0, 100, 88));
|
||||
let image_shallow_water = pixbuf_from_image_tile(image.clone().crop(100, 0, 100, 88));
|
||||
let image_grasslands = pixbuf_from_image_tile(image.clone().crop(200, 0, 100, 88));
|
||||
let image_desert = pixbuf_from_image_tile(image.clone().crop(300, 0, 100, 88));
|
||||
let image_mountain = pixbuf_from_image_tile(image.clone().crop(0, 88, 100, 88));
|
||||
let image_badlands = pixbuf_from_image_tile(image.clone().crop(100, 88, 100, 88));
|
||||
let image_swamp = pixbuf_from_image_tile(image.clone().crop(0, 176, 100, 88));
|
||||
|
||||
/*
|
||||
let image_pb = Pixbuf::from_bytes(
|
||||
&glib::Bytes::from(image.as_bytes()),
|
||||
gtk::gdk_pixbuf::Colorspace::Rgb,
|
||||
false,
|
||||
8,
|
||||
image.width() as i32,
|
||||
image.height() as i32,
|
||||
image.to_rgb8().sample_layout().height_stride as i32,
|
||||
);
|
||||
*/
|
||||
|
||||
let motion_controller = gtk::EventControllerMotion::new();
|
||||
{
|
||||
let canvas_address = self.canvas_address.clone();
|
||||
let hex_address = self.hex_address.clone();
|
||||
let c = self.current_coordinate.clone();
|
||||
motion_controller.connect_motion(move |_, x, y| {
|
||||
let norm_x = x - DRAWING_ORIGIN.0;
|
||||
let norm_y = y - DRAWING_ORIGIN.1;
|
||||
let q = (2. / 3. * norm_x) / HEX_RADIUS;
|
||||
let r = (-1. / 3. * norm_x + (3. as f64).sqrt() / 3. * norm_y) / HEX_RADIUS;
|
||||
|
||||
let (q, r) = axial_round(q, r);
|
||||
let coordinate = AxialAddr::new(q, r);
|
||||
canvas_address.set_label(&format!("{:.0} {:.0}", x, y));
|
||||
|
||||
if coordinate.distance(&AxialAddr::origin()) > MAP_RADIUS {
|
||||
hex_address.set_label(&format!("-----"));
|
||||
*c.borrow_mut() = None;
|
||||
} else {
|
||||
hex_address.set_label(&format!("{:.0} {:.0}", coordinate.q(), coordinate.r()));
|
||||
*c.borrow_mut() = Some(coordinate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
{
|
||||
self.drawing_area.set_draw_func(move |_, context, _, _| {
|
||||
context.set_source_rgb(0., 0., 0.);
|
||||
let _ = context.paint();
|
||||
|
||||
context.set_line_width(2.);
|
||||
|
||||
let clip_path = hexagon_path(context, 100., 88.);
|
||||
context.set_source_pixbuf(&image_deep_water, 0., 0.);
|
||||
context.append_path(&clip_path);
|
||||
context.clip();
|
||||
context.paint().expect("paint should succeed");
|
||||
|
||||
context.set_source_pixbuf(&image_shallow_water, 150., 0.);
|
||||
context.paint().expect("paint should succeed");
|
||||
|
||||
context.set_source_pixbuf(&image_grasslands, 300., 0.);
|
||||
context.paint().expect("paint should succeed");
|
||||
|
||||
context.set_source_pixbuf(&image_desert, 450., 0.);
|
||||
context.paint().expect("paint should succeed");
|
||||
|
||||
context.set_source_pixbuf(&image_mountain, 0., 100.);
|
||||
context.paint().expect("paint should succeed");
|
||||
|
||||
context.set_source_pixbuf(&image_badlands, 150., 100.);
|
||||
context.paint().expect("paint should succeed");
|
||||
|
||||
context.set_source_pixbuf(&image_swamp, 0., 200.);
|
||||
context.paint().expect("paint should succeed");
|
||||
/*
|
||||
for coordinate in vec![AxialAddr::origin()]
|
||||
.into_iter()
|
||||
.chain(AxialAddr::origin().addresses(MAP_RADIUS))
|
||||
{
|
||||
let center_x =
|
||||
DRAWING_ORIGIN.0 + HEX_RADIUS * (3. / 2. * (coordinate.q() as f64));
|
||||
let center_y = DRAWING_ORIGIN.1
|
||||
+ HEX_RADIUS
|
||||
* ((3. as f64).sqrt() / 2. * (coordinate.q() as f64)
|
||||
+ (3. as f64).sqrt() * (coordinate.r() as f64));
|
||||
|
||||
let tile = hex_map.get(&coordinate).unwrap();
|
||||
let color = tile.color();
|
||||
context.set_source_rgb(color.0, color.1, color.2);
|
||||
|
||||
draw_hexagon(context, center_x, center_y, HEX_RADIUS);
|
||||
let _ = context.fill();
|
||||
}
|
||||
*/
|
||||
});
|
||||
}
|
||||
self.drawing_area.add_controller(&motion_controller);
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for HexGridWindowPrivate {}
|
||||
impl WindowImpl for HexGridWindowPrivate {}
|
||||
impl ApplicationWindowImpl for HexGridWindowPrivate {}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct HexGridWindow(ObjectSubclass<HexGridWindowPrivate>) @extends gtk::ApplicationWindow, gtk::Window, gtk::Widget,
|
||||
@implements gtk::Accessible, gtk::Actionable, gtk::Buildable, gtk::ConstraintTarget;
|
||||
}
|
||||
|
||||
impl HexGridWindow {
|
||||
pub fn new(app: &Application) -> Self {
|
||||
Object::builder().property("application", app).build()
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_hexagon(context: &Context, center_x: f64, center_y: f64, radius: f64) {
|
||||
let ul_x = center_x - radius;
|
||||
let ul_y = center_y - (3. as f64).sqrt() * radius / 2.;
|
||||
let points: Vec<(f64, f64)> = hexagon(radius * 2., (3. as f64).sqrt() * radius);
|
||||
context.new_path();
|
||||
context.move_to(ul_x + points[0].0, ul_y + points[0].1);
|
||||
context.line_to(ul_x + points[1].0, ul_y + points[1].1);
|
||||
context.line_to(ul_x + points[2].0, ul_y + points[2].1);
|
||||
context.line_to(ul_x + points[3].0, ul_y + points[3].1);
|
||||
context.line_to(ul_x + points[4].0, ul_y + points[4].1);
|
||||
context.line_to(ul_x + points[5].0, ul_y + points[5].1);
|
||||
context.close_path();
|
||||
}
|
||||
|
||||
fn hexagon_path(context: &Context, width: f64, height: f64) -> Path {
|
||||
context.new_path();
|
||||
let points = hexagon(width, height);
|
||||
context.move_to(points[0].0, points[0].1);
|
||||
context.line_to(points[1].0, points[1].1);
|
||||
context.line_to(points[2].0, points[2].1);
|
||||
context.line_to(points[3].0, points[3].1);
|
||||
context.line_to(points[4].0, points[4].1);
|
||||
context.line_to(points[5].0, points[5].1);
|
||||
context.copy_path().expect("to successfully copy a path")
|
||||
}
|
||||
|
||||
fn hexagon(width: f64, height: f64) -> Vec<(f64, f64)> {
|
||||
let center_x = width / 2.;
|
||||
let center_y = height / 2.;
|
||||
let radius = width / 2.;
|
||||
|
||||
vec![
|
||||
(center_x + radius, center_y),
|
||||
(
|
||||
center_x + radius / 2.,
|
||||
center_y + (3. as f64).sqrt() * radius / 2.,
|
||||
),
|
||||
(
|
||||
center_x - radius / 2.,
|
||||
center_y + (3. as f64).sqrt() * radius / 2.,
|
||||
),
|
||||
(center_x - radius, center_y),
|
||||
(
|
||||
center_x - radius / 2.,
|
||||
center_y - (3. as f64).sqrt() * radius / 2.,
|
||||
),
|
||||
(
|
||||
center_x + radius / 2.,
|
||||
center_y - (3. as f64).sqrt() * radius / 2.,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
fn axial_round(q_f64: f64, r_f64: f64) -> (i32, i32) {
|
||||
let s_f64 = -q_f64 - r_f64;
|
||||
let mut q = q_f64.round();
|
||||
let mut r = r_f64.round();
|
||||
let s = s_f64.round();
|
||||
|
||||
let q_diff = (q - q_f64).abs();
|
||||
let r_diff = (r - r_f64).abs();
|
||||
let s_diff = (s - s_f64).abs();
|
||||
|
||||
if q_diff > r_diff && q_diff > s_diff {
|
||||
q = -r - s;
|
||||
} else if r_diff > s_diff {
|
||||
r = -q - s;
|
||||
}
|
||||
unsafe { (q.to_int_unchecked::<i32>(), r.to_int_unchecked::<i32>()) }
|
||||
}
|
||||
|
||||
fn pixbuf_from_image_tile(image: image::DynamicImage) -> Pixbuf {
|
||||
Pixbuf::from_bytes(
|
||||
&glib::Bytes::from(image.as_bytes()),
|
||||
gtk::gdk_pixbuf::Colorspace::Rgb,
|
||||
false,
|
||||
8,
|
||||
image.width() as i32,
|
||||
image.height() as i32,
|
||||
image.to_rgb8().sample_layout().height_stride as i32,
|
||||
)
|
||||
}
|
|
@ -6,6 +6,8 @@ authors = ["Savanni D'Gerinel <savanni@luminescent-dreams.com>"]
|
|||
edition = "2018"
|
||||
keywords = ["date", "time", "calendar"]
|
||||
categories = ["date-and-time"]
|
||||
license = "GPL-3.0-only"
|
||||
license-file = "../COPYING"
|
||||
|
||||
[dependencies]
|
||||
chrono = "0.4"
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern crate chrono;
|
||||
extern crate chrono_tz;
|
||||
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
extern crate chrono;
|
||||
extern crate chrono_tz;
|
||||
extern crate international_fixed_calendar as IFC;
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
/*
|
||||
Copyright 2020-2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use chrono::{Datelike, Utc};
|
||||
use international_fixed_calendar as IFC;
|
||||
use iron::headers;
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<link rel="stylesheet" href="./styles.css" type="text/css" />
|
||||
<title>Music Player</title>
|
||||
</head>
|
||||
<body>
|
||||
<div class="currently-playing"> <span class="track-title"> Lindsey Sterling - Elements </span> <span class="player-status">[paused]</span> </div>
|
||||
<div class="controls"><button class="play-pause">Pause</button></div>
|
||||
|
||||
<div class="track-list">
|
||||
<div class="track-list__grouping">
|
||||
<ul class="bulletless-list">
|
||||
<li> By Artist </li>
|
||||
<li> By Album </li>
|
||||
<li> Work Music </li>
|
||||
<li> Dance Music </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="track-list__tracks">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> Track # </th>
|
||||
<th> Title </th>
|
||||
<th> Artist </th>
|
||||
<th> Album </th>
|
||||
<th> Length </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr class="track-list__track-row">
|
||||
<td> 1 </td>
|
||||
<td> Underground </td>
|
||||
<td> Lindsey Stirling </td>
|
||||
<td> Artemis </td>
|
||||
<td> 4:24 </td>
|
||||
</tr>
|
||||
<tr class="track-list__track-row">
|
||||
<td> 2 </td>
|
||||
<td> Artemis </td>
|
||||
<td> Lindsey Stirling </td>
|
||||
<td> Artemis </td>
|
||||
<td> 3:54 </td>
|
||||
</tr>
|
||||
<tr class="track-list__track-row">
|
||||
<td> 3 </td>
|
||||
<td> Til the Light Goes Out </td>
|
||||
<td> Lindsey Stirling </td>
|
||||
<td> Artemis </td>
|
||||
<td> 4:46 </td>
|
||||
</tr>
|
||||
<tr class="track-list__track-row">
|
||||
<td> 4 </td>
|
||||
<td> Between Twilight </td>
|
||||
<td> Lindsey Stirling </td>
|
||||
<td> Artemis </td>
|
||||
<td> 4:20 </td>
|
||||
</tr>
|
||||
<tr class="track-list__track-row">
|
||||
<td> 5 </td>
|
||||
<td> Foreverglow </td>
|
||||
<td> Lindsey Stirling </td>
|
||||
<td> Artemis </td>
|
||||
<td> 3:58 </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="./dist/main.js" type="module"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"name": "music-player-client",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"build": "browserify src/main.ts -p [ tsify ] > dist/bundle.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"watch": "exa index.html styles.css src/* | entr -s 'npm run build'"
|
||||
},
|
||||
"author": "Savanni D'Gerinel <savanni@luminescent-dreams.com>",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.21",
|
||||
"systemjs": "^6.13.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/lodash": "^4.14.191",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "^17.0.0",
|
||||
"live-server": "^1.2.2",
|
||||
"tsify": "^5.0.4",
|
||||
"typescript": "^4.9.4",
|
||||
"watchify": "^4.0.0"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
import * as _ from "lodash";
|
||||
|
||||
const replaceTitle = () => {
|
||||
const title = document.querySelector(".js-title");
|
||||
if (title && title.innerHTML) {
|
||||
title.innerHTML = "Music Player Paused";
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
const checkWeatherService = () => {
|
||||
fetch("https://api.weather.gov/")
|
||||
.then((r) => r.json())
|
||||
.then((js) => {
|
||||
const weather = document.querySelector('.js-weather');
|
||||
weather.innerHTML = js.status;
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
const run = () => {
|
||||
replaceTitle();
|
||||
console.log(_.map([4, 8], (x) => x * x));
|
||||
// checkWeatherService();
|
||||
};
|
||||
|
||||
run();
|
|
@ -0,0 +1,39 @@
|
|||
body {
|
||||
background-color: rgb(240, 230, 230);
|
||||
}
|
||||
|
||||
.currently-playing {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.controls {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
.track-list {
|
||||
border: 1px solid black;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.track-list__grouping {
|
||||
padding: 8px;
|
||||
border-style: solid;
|
||||
border-width: 0px 5px 0px 0px;
|
||||
}
|
||||
|
||||
.bulletless-list {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.track-list__track-row {
|
||||
background-color: rgb(10, 10, 10);
|
||||
}
|
||||
|
||||
.track-list__track-row:nth-child(even) {
|
||||
background-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
.track-list__track-row:nth-child(odd) {
|
||||
background-color: rgb(200, 200, 200);
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target": "es2015",
|
||||
"module": "commonjs",
|
||||
"moduleResolution": "node",
|
||||
"rootDir": "src",
|
||||
"outDir": "./dist",
|
||||
"lib": ["es2016", "DOM"],
|
||||
"sourceMap": true
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
pub use flow::error;
|
||||
|
||||
pub enum FatalError {
|
||||
UnexpectedError,
|
||||
}
|
||||
|
||||
impl flow::FatalError for FatalError {}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,20 @@
|
|||
[package]
|
||||
name = "music-player"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
dbus = { version = "0.9.7" }
|
||||
flow = { path = "../../flow" }
|
||||
mpris = { version = "2.0" }
|
||||
rusqlite = { version = "0.28" }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
thiserror = { version = "1.0" }
|
||||
tokio = { version = "1.24", features = ["full"] }
|
||||
url = { version = "2.3" }
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
warp = { version = "0.3" }
|
||||
|
||||
[lib]
|
|
@ -0,0 +1,308 @@
|
|||
/*
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
use dbus::ffidisp::Connection;
|
||||
use mpris::{FindingError, PlaybackStatus, Player, PlayerFinder, ProgressTick};
|
||||
use serde::Serialize;
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::mpsc::{channel, Receiver, Sender, TryRecvError},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
pub enum Message {
|
||||
Quit,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Event {
|
||||
Paused(Track, Duration),
|
||||
Playing(Track, Duration),
|
||||
Stopped,
|
||||
Position(Track, Duration),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct DeviceInformation {
|
||||
pub address: String,
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
pub fn list_devices(conn: Connection) -> Result<Vec<DeviceInformation>, FindingError> {
|
||||
Ok(PlayerFinder::for_connection(conn)
|
||||
.find_all()?
|
||||
.into_iter()
|
||||
.map(|player| DeviceInformation {
|
||||
address: player.unique_name().to_owned(),
|
||||
name: player.identity().to_owned(),
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum AudioError {
|
||||
#[error("DBus device was not found")]
|
||||
DeviceNotFound,
|
||||
|
||||
#[error("DBus connection lost or otherwise failed")]
|
||||
ConnectionLost,
|
||||
|
||||
#[error("Specified media cannot be found")]
|
||||
MediaNotFound,
|
||||
|
||||
#[error("Play was ordered, but nothing is in the queue")]
|
||||
NothingInQueue,
|
||||
|
||||
#[error("Unknown dbus error")]
|
||||
DbusError(dbus::Error),
|
||||
|
||||
#[error("Unknown problem with mpris")]
|
||||
MprisError(mpris::DBusError),
|
||||
|
||||
#[error("url parse error {0}")]
|
||||
UrlError(url::ParseError),
|
||||
}
|
||||
|
||||
impl From<dbus::Error> for AudioError {
|
||||
fn from(err: dbus::Error) -> Self {
|
||||
Self::DbusError(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<mpris::DBusError> for AudioError {
|
||||
fn from(err: mpris::DBusError) -> Self {
|
||||
Self::MprisError(err)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<url::ParseError> for AudioError {
|
||||
fn from(err: url::ParseError) -> Self {
|
||||
Self::UrlError(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Eq, Hash, PartialEq, Serialize)]
|
||||
pub struct TrackId(String);
|
||||
|
||||
impl Default for TrackId {
|
||||
fn default() -> Self {
|
||||
Self(uuid::Uuid::new_v4().as_hyphenated().to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl From<String> for TrackId {
|
||||
fn from(id: String) -> Self {
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl AsRef<String> for TrackId {
|
||||
fn as_ref<'a>(&'a self) -> &'a String {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct TrackInfo {
|
||||
pub track_number: Option<i32>,
|
||||
pub name: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub artist: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Track {
|
||||
pub id: TrackId,
|
||||
pub track_number: Option<i32>,
|
||||
pub name: Option<String>,
|
||||
pub album: Option<String>,
|
||||
pub artist: Option<String>,
|
||||
}
|
||||
|
||||
/*
|
||||
impl From<&mpris::Metadata> for Track {
|
||||
fn from(data: &mpris::Metadata) -> Self {
|
||||
Self {
|
||||
id: data.track_id().unwrap(),
|
||||
track_number: data.track_number(),
|
||||
name: data.title().map(|s| s.to_owned()),
|
||||
album: data.album_name().map(|s| s.to_owned()),
|
||||
artist: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<mpris::Metadata> for Track {
|
||||
fn from(data: mpris::Metadata) -> Self {
|
||||
Self::from(&data)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum State {
|
||||
Playing(Track),
|
||||
Paused(Track),
|
||||
Stopped,
|
||||
}
|
||||
|
||||
pub struct CurrentlyPlaying {
|
||||
track: Track,
|
||||
position: Duration,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Capabilities {
|
||||
pub can_control: bool,
|
||||
pub can_pause: bool,
|
||||
pub can_play: bool,
|
||||
pub supports_track_lists: bool,
|
||||
}
|
||||
|
||||
pub trait AudioPlayer {
|
||||
fn capabilities(&self) -> Result<Capabilities, AudioError>;
|
||||
fn state(&self) -> Result<State, AudioError>;
|
||||
fn play(&self, trackid: url::Url) -> Result<State, AudioError>;
|
||||
fn play_pause(&self) -> Result<State, AudioError>;
|
||||
}
|
||||
|
||||
pub struct GStreamerPlayer {
|
||||
url: url::Url,
|
||||
}
|
||||
|
||||
impl AudioPlayer for GStreamerPlayer {
|
||||
fn capabilities(&self) -> Result<Capabilities, AudioError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn state(&self) -> Result<State, AudioError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn play(&self, trackid: url::Url) -> Result<State, AudioError> {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn play_pause(&self) -> Result<State, AudioError> {
|
||||
unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
pub struct MprisDevice {
|
||||
device_id: String,
|
||||
player: Player,
|
||||
state: State,
|
||||
}
|
||||
|
||||
impl MprisDevice {
|
||||
pub fn new(device_id: String) -> Result<MprisDevice, AudioError> {
|
||||
let connection = Connection::new_session()?;
|
||||
Ok(MprisDevice {
|
||||
device_id: device_id.clone(),
|
||||
player: mpris::Player::new(connection, device_id, 1000)?,
|
||||
state: State::Stopped,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn monitor(&mut self, control_channel: Receiver<Message>) {
|
||||
let (tx, rx) = channel();
|
||||
{
|
||||
let device_id = self.device_id.clone();
|
||||
let tx = tx.clone();
|
||||
thread::spawn(move || {
|
||||
MprisDevice::new(device_id)
|
||||
.expect("connect to bus")
|
||||
.monitor_progress(tx);
|
||||
});
|
||||
};
|
||||
|
||||
loop {
|
||||
match control_channel.try_recv() {
|
||||
Ok(Message::Quit) => return,
|
||||
Err(TryRecvError::Empty) => {}
|
||||
Err(TryRecvError::Disconnected) => return,
|
||||
}
|
||||
let event = rx.recv().expect("receive should never fail");
|
||||
println!("event received: {:?}", event);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn monitor_progress(&self, tx: Sender<Event>) {
|
||||
let mut tracker = self
|
||||
.player
|
||||
.track_progress(1000)
|
||||
.expect("can get an event stream");
|
||||
loop {
|
||||
let ProgressTick { progress, .. } = tracker.tick();
|
||||
match progress.playback_status() {
|
||||
PlaybackStatus::Playing => {
|
||||
tx.send(Event::Playing(
|
||||
Track::from(progress.metadata()),
|
||||
progress.position(),
|
||||
))
|
||||
.expect("send to succeed");
|
||||
}
|
||||
PlaybackStatus::Paused => {
|
||||
tx.send(Event::Paused(
|
||||
Track::from(progress.metadata()),
|
||||
progress.position(),
|
||||
))
|
||||
.expect("send to succeed");
|
||||
}
|
||||
PlaybackStatus::Stopped => {
|
||||
tx.send(Event::Stopped).expect("send to succeed");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl AudioPlayer for MprisDevice {
|
||||
fn capabilities(&self) -> Result<Capabilities, AudioError> {
|
||||
Ok(Capabilities {
|
||||
can_control: self.player.can_control()?,
|
||||
can_pause: self.player.can_pause()?,
|
||||
can_play: self.player.can_play()?,
|
||||
supports_track_lists: self.player.supports_track_lists(),
|
||||
})
|
||||
}
|
||||
|
||||
fn state(&self) -> Result<State, AudioError> {
|
||||
println!(
|
||||
"supports track lists: {:?}",
|
||||
self.player.supports_track_lists()
|
||||
);
|
||||
let metadata = self.player.get_metadata()?;
|
||||
println!("{:?}", metadata);
|
||||
unimplemented!("AudioPlayer state")
|
||||
}
|
||||
|
||||
fn play(&self, track_id: String) -> Result<State, AudioError> {
|
||||
println!("playing: {}", track_id);
|
||||
self.player
|
||||
.go_to(&mpris::TrackID::from(dbus::Path::from(track_id)))?;
|
||||
self.player.play();
|
||||
Ok(State::Stopped)
|
||||
}
|
||||
|
||||
fn play_pause(&self) -> Result<State, AudioError> {
|
||||
self.player.play_pause()?;
|
||||
Ok(State::Stopped)
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -0,0 +1,114 @@
|
|||
use flow::Flow;
|
||||
use std::{io::stdin, path::PathBuf, sync::Arc, thread, time::Duration};
|
||||
// use warp::Filter;
|
||||
|
||||
use music_player::{core::Core, database::MemoryIndex};
|
||||
|
||||
/*
|
||||
fn tracks() -> Vec<Track> {
|
||||
vec![
|
||||
Track {
|
||||
track_number: Some(1),
|
||||
name: Some("Underground".to_owned()),
|
||||
album: Some("Artemis".to_owned()),
|
||||
artist: Some("Lindsey Stirling".to_owned()),
|
||||
path: PathBuf::from("/mnt/music/Lindsey Stirling/Artemis/01 - Underground.ogg"),
|
||||
},
|
||||
Track {
|
||||
track_number: Some(2),
|
||||
name: Some("Artemis".to_owned()),
|
||||
album: Some("Artemis".to_owned()),
|
||||
artist: Some("Lindsey Stirling".to_owned()),
|
||||
path: PathBuf::from("/mnt/music/Lindsey Stirling/Artemis/02 - Artemis.ogg"),
|
||||
},
|
||||
Track {
|
||||
track_number: Some(3),
|
||||
name: Some("Til the Light Goes Out".to_owned()),
|
||||
album: Some("Artemis".to_owned()),
|
||||
artist: Some("Lindsey Stirling".to_owned()),
|
||||
path: PathBuf::from(
|
||||
"/mnt/music/Lindsey Stirling/Artemis/03 - Til the Light Goes Out.ogg",
|
||||
),
|
||||
},
|
||||
Track {
|
||||
track_number: Some(4),
|
||||
name: Some("Between Twilight".to_owned()),
|
||||
album: Some("Artemis".to_owned()),
|
||||
artist: Some("Lindsey Stirling".to_owned()),
|
||||
path: PathBuf::from("/mnt/music/Lindsey Stirling/Artemis/04 - Between Twilight.ogg"),
|
||||
},
|
||||
Track {
|
||||
track_number: Some(5),
|
||||
name: Some("Foreverglow".to_owned()),
|
||||
album: Some("Artemis".to_owned()),
|
||||
artist: Some("Lindsey Stirling".to_owned()),
|
||||
path: PathBuf::from("/mnt/music/Lindsey Stirling/Artemis/05 - Foreverglow.ogg"),
|
||||
},
|
||||
]
|
||||
}
|
||||
*/
|
||||
|
||||
#[tokio::main]
|
||||
pub async fn main() {
|
||||
match Core::new(Arc::new(MemoryIndex::new())) {
|
||||
Flow::Ok(core) => {
|
||||
let mut buf = String::new();
|
||||
let _ = stdin().read_line(&mut buf).unwrap();
|
||||
core.exit();
|
||||
}
|
||||
Flow::Err(err) => println!("non-fatal error: {:?}", err),
|
||||
Flow::Fatal(err) => println!("fatal error: {:?}", err),
|
||||
}
|
||||
|
||||
/*
|
||||
let connection = Connection::new_session().expect("to connect to dbus");
|
||||
|
||||
for player in list_players(connection) {
|
||||
println!("player found: {}", player.identity());
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
let devices = warp::path!("api" / "v1" / "devices")
|
||||
.and(warp::get())
|
||||
.map(|| {
|
||||
let conn = Connection::new_session().expect("to connect to dbus");
|
||||
warp::reply::json(&list_devices(conn))
|
||||
});
|
||||
|
||||
let track_list = warp::path!("api" / "v1" / "tracks")
|
||||
.and(warp::get())
|
||||
.map(|| warp::reply::json(&tracks()));
|
||||
let tracks_for_artist = warp::path!("api" / "v1" / "artist" / String)
|
||||
.and(warp::get())
|
||||
.map(|_artist: String| warp::reply::json(&tracks()));
|
||||
let tracks_for_album = warp::path!("api" / "v1" / "album" / String)
|
||||
.and(warp::get())
|
||||
.map(|_album: String| warp::reply::json(&tracks()));
|
||||
|
||||
let queue = warp::path!("api" / "v1" / "queue")
|
||||
.and(warp::get())
|
||||
.map(|| {
|
||||
let conn = Connection::new_session().expect("to connect to dbus");
|
||||
warp::reply::json(&list_tracks(conn))
|
||||
});
|
||||
|
||||
let playing_status = warp::path!("api" / "v1" / "play-pause")
|
||||
.and(warp::get())
|
||||
.map(|| warp::reply::json(&PlayPause::Paused));
|
||||
|
||||
let routes = devices
|
||||
.or(track_list)
|
||||
.or(tracks_for_album)
|
||||
.or(tracks_for_artist)
|
||||
.or(queue)
|
||||
.or(playing_status);
|
||||
let server = warp::serve(routes);
|
||||
server
|
||||
.run(SocketAddr::new(
|
||||
IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)),
|
||||
8002,
|
||||
))
|
||||
.await;
|
||||
*/
|
||||
}
|
|
@ -0,0 +1,181 @@
|
|||
use crate::{
|
||||
database::{Database, MemoryIndex, MusicIndex},
|
||||
Error, FatalError,
|
||||
};
|
||||
use flow::{error, fatal, ok, return_error, return_fatal, Flow};
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::{
|
||||
mpsc::{channel, Receiver, RecvTimeoutError, Sender},
|
||||
Arc,
|
||||
},
|
||||
thread,
|
||||
thread::JoinHandle,
|
||||
time::{Duration, Instant},
|
||||
};
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ScannerError {
|
||||
#[error("Cannot scan {0}")]
|
||||
CannotScan(PathBuf),
|
||||
#[error("IO error {0}")]
|
||||
IO(std::io::Error),
|
||||
}
|
||||
|
||||
impl From<std::io::Error> for ScannerError {
|
||||
fn from(err: std::io::Error) -> Self {
|
||||
Self::IO(err)
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ControlMsg {
|
||||
Exit,
|
||||
}
|
||||
|
||||
pub enum TrackMsg {
|
||||
DbUpdate,
|
||||
}
|
||||
|
||||
pub enum PlaybackMsg {
|
||||
PositionUpdate,
|
||||
Playing,
|
||||
Pausing,
|
||||
Stopping,
|
||||
}
|
||||
|
||||
pub struct Core {
|
||||
db: Arc<dyn MusicIndex>,
|
||||
track_handle: JoinHandle<()>,
|
||||
track_rx: Receiver<TrackMsg>,
|
||||
playback_handle: JoinHandle<()>,
|
||||
playback_rx: Receiver<PlaybackMsg>,
|
||||
control_tx: Sender<ControlMsg>,
|
||||
}
|
||||
|
||||
fn scan_frequency() -> Duration {
|
||||
Duration::from_secs(60)
|
||||
}
|
||||
|
||||
pub struct FileScanner {
|
||||
db: Arc<dyn MusicIndex>,
|
||||
control_rx: Receiver<ControlMsg>,
|
||||
tracker_tx: Sender<TrackMsg>,
|
||||
next_scan: Instant,
|
||||
music_directories: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
impl FileScanner {
|
||||
fn new(
|
||||
db: Arc<dyn MusicIndex>,
|
||||
roots: Vec<PathBuf>,
|
||||
control_rx: Receiver<ControlMsg>,
|
||||
tracker_tx: Sender<TrackMsg>,
|
||||
) -> Self {
|
||||
Self {
|
||||
db,
|
||||
control_rx,
|
||||
tracker_tx,
|
||||
next_scan: Instant::now(),
|
||||
music_directories: roots,
|
||||
}
|
||||
}
|
||||
|
||||
fn scan(&mut self) {
|
||||
loop {
|
||||
match self.control_rx.recv_timeout(Duration::from_millis(100)) {
|
||||
Ok(ControlMsg::Exit) => return,
|
||||
Err(RecvTimeoutError::Timeout) => (),
|
||||
Err(RecvTimeoutError::Disconnected) => return,
|
||||
}
|
||||
if Instant::now() >= self.next_scan {
|
||||
for root in self.music_directories.iter() {
|
||||
self.scan_dir(vec![root.clone()]);
|
||||
}
|
||||
self.next_scan = Instant::now() + scan_frequency();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn scan_dir(&self, mut paths: Vec<PathBuf>) -> Flow<(), FatalError, ScannerError> {
|
||||
while let Some(dir) = paths.pop() {
|
||||
println!("scanning {:?}", dir);
|
||||
return_error!(self.scan_dir_(&mut paths, dir));
|
||||
}
|
||||
ok(())
|
||||
}
|
||||
|
||||
fn scan_dir_(
|
||||
&self,
|
||||
paths: &mut Vec<PathBuf>,
|
||||
dir: PathBuf,
|
||||
) -> Flow<(), FatalError, ScannerError> {
|
||||
let dir_iter = return_error!(Flow::from(dir.read_dir().map_err(ScannerError::from)));
|
||||
for entry in dir_iter {
|
||||
match entry {
|
||||
Ok(entry) if entry.path().is_dir() => paths.push(entry.path()),
|
||||
Ok(entry) => {
|
||||
let _ = return_fatal!(self.scan_file(entry.path()).or_else(|err| {
|
||||
println!("scan_file failed: {:?}", err);
|
||||
ok::<(), FatalError, ScannerError>(())
|
||||
}));
|
||||
()
|
||||
}
|
||||
Err(err) => {
|
||||
println!("scan_dir could not read path: ({:?})", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
ok(())
|
||||
}
|
||||
|
||||
fn scan_file(&self, path: PathBuf) -> Flow<(), FatalError, ScannerError> {
|
||||
ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Core {
|
||||
pub fn new(db: Arc<dyn MusicIndex>) -> Flow<Core, FatalError, Error> {
|
||||
let (control_tx, control_rx) = channel::<ControlMsg>();
|
||||
|
||||
let (track_handle, track_rx) = {
|
||||
let (track_tx, track_rx) = channel();
|
||||
let db = db.clone();
|
||||
let track_handle = thread::spawn(move || {
|
||||
FileScanner::new(
|
||||
db,
|
||||
vec![PathBuf::from("/home/savanni/Music/")],
|
||||
control_rx,
|
||||
track_tx,
|
||||
)
|
||||
.scan();
|
||||
});
|
||||
(track_handle, track_rx)
|
||||
};
|
||||
|
||||
let (playback_handle, playback_rx) = {
|
||||
let (playback_tx, playback_rx) = channel();
|
||||
let playback_handle = thread::spawn(move || {});
|
||||
(playback_handle, playback_rx)
|
||||
};
|
||||
|
||||
ok(Core {
|
||||
db,
|
||||
track_handle,
|
||||
track_rx,
|
||||
playback_handle,
|
||||
playback_rx,
|
||||
control_tx,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn exit(&self) {
|
||||
let _ = self.control_tx.send(ControlMsg::Exit);
|
||||
/*
|
||||
self.track_handle.join();
|
||||
self.playback_handle.join();
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test {}
|
|
@ -0,0 +1,106 @@
|
|||
use crate::{
|
||||
audio::{Track, TrackId, TrackInfo},
|
||||
FatalError,
|
||||
};
|
||||
use flow::{error, ok, Flow};
|
||||
use rusqlite::Connection;
|
||||
use std::collections::HashMap;
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
sync::{Arc, Mutex, RwLock},
|
||||
};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum DatabaseError {
|
||||
#[error("database is unreadable")]
|
||||
DatabaseUnreadable,
|
||||
#[error("unhandled database problem: {0}")]
|
||||
UnhandledError(rusqlite::Error),
|
||||
}
|
||||
|
||||
pub trait MusicIndex: Sync + Send {
|
||||
fn add_track(&mut self, track: &TrackInfo) -> Flow<Track, FatalError, DatabaseError>;
|
||||
fn remove_track(&mut self, id: &TrackId) -> Flow<(), FatalError, DatabaseError>;
|
||||
fn get_track_info(&self, id: &TrackId) -> Flow<Option<Track>, FatalError, DatabaseError>;
|
||||
}
|
||||
|
||||
pub struct MemoryIndex {
|
||||
tracks: RwLock<HashMap<TrackId, Track>>,
|
||||
}
|
||||
|
||||
impl MemoryIndex {
|
||||
pub fn new() -> MemoryIndex {
|
||||
MemoryIndex {
|
||||
tracks: RwLock::new(HashMap::default()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MusicIndex for MemoryIndex {
|
||||
fn add_track(&mut self, info: &TrackInfo) -> Flow<Track, FatalError, DatabaseError> {
|
||||
let id = TrackId::default();
|
||||
let track = Track {
|
||||
id: id.clone(),
|
||||
track_number: info.track_number,
|
||||
name: info.name.clone(),
|
||||
album: info.album.clone(),
|
||||
artist: info.artist.clone(),
|
||||
};
|
||||
let mut tracks = self.tracks.write().unwrap();
|
||||
tracks.insert(id, track.clone());
|
||||
ok(track)
|
||||
}
|
||||
|
||||
fn remove_track(&mut self, id: &TrackId) -> Flow<(), FatalError, DatabaseError> {
|
||||
let mut tracks = self.tracks.write().unwrap();
|
||||
tracks.remove(&id);
|
||||
ok(())
|
||||
}
|
||||
|
||||
fn get_track_info<'a>(
|
||||
&'a self,
|
||||
id: &TrackId,
|
||||
) -> Flow<Option<Track>, FatalError, DatabaseError> {
|
||||
let track = {
|
||||
let tracks = self.tracks.read().unwrap();
|
||||
tracks.get(&id).cloned()
|
||||
};
|
||||
ok(track)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ManagedConnection<'a> {
|
||||
pool: &'a Database,
|
||||
conn: Option<Connection>,
|
||||
}
|
||||
|
||||
impl<'a> Drop for ManagedConnection<'a> {
|
||||
fn drop(&mut self) {
|
||||
self.pool.r(self.conn.take().unwrap());
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Database {
|
||||
path: PathBuf,
|
||||
pool: Arc<Mutex<Vec<Connection>>>,
|
||||
}
|
||||
|
||||
impl Database {
|
||||
pub fn new(path: PathBuf) -> Flow<Database, FatalError, DatabaseError> {
|
||||
let connection = match Connection::open(path.clone()) {
|
||||
Ok(connection) => connection,
|
||||
Err(err) => return error(DatabaseError::UnhandledError(err)),
|
||||
};
|
||||
ok(Database {
|
||||
path,
|
||||
pool: Arc::new(Mutex::new(vec![connection])),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn r(&self, conn: Connection) {
|
||||
let mut pool = self.pool.lock().unwrap();
|
||||
pool.push(conn);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
pub mod audio;
|
||||
pub mod core;
|
||||
pub mod database;
|
||||
use database::DatabaseError;
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
#[error("Database error: {0}")]
|
||||
DatabaseError(DatabaseError),
|
||||
}
|
||||
|
||||
impl From<DatabaseError> for Error {
|
||||
fn from(err: DatabaseError) -> Self {
|
||||
Self::DatabaseError(err)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum FatalError {
|
||||
#[error("Unexpected error")]
|
||||
UnexpectedError,
|
||||
}
|
||||
|
||||
impl flow::FatalError for FatalError {}
|
|
@ -0,0 +1,514 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b0357a6402b295ca3a86bc148e84df46c02e41f41fef186bda662557ef6328aa"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e5317663a9089767a1ec00a487df42e0ca174b61b4483213ac24448e4664df5"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec90ff4d0fe1f57d600049061dc6bb68ed03c7d2fbd697274c41805dcb3f8608"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8de0a35a6ab97ec8869e32a2473f4b1324459e14c29275d14b10cb1fd19b50e"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95a73af87da33b5acf53acfebdc339fe592ecf5357ac7c0a7734ab9d8c876a70"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcf79a1bf610b10f42aea489289c5a2c478a786509693b80cd39c44ccd936366"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c1d6de3acfef38d2be4b1f543f553131788603495be83da675e180c8d6b7bd1"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-macro",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.16.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ddd4df61a866ed7259d6189b8bcb1464989a77f1d85d25d002279bbe9dd38b2f"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib-macros",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e084807350b01348b6d9dbabb724d1a0bb987f47a2c85de200e98e12e30733bf"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"proc-macro-crate",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.16.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer"
|
||||
version = "0.19.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "61af131b56332ec386a8ea538d961d0c6937054fb2771a9a505395f8471b7b0e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"glib",
|
||||
"gstreamer-sys",
|
||||
"libc",
|
||||
"muldiv",
|
||||
"num-integer",
|
||||
"num-rational",
|
||||
"once_cell",
|
||||
"option-operations",
|
||||
"paste",
|
||||
"pretty-hex",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gstreamer-sys"
|
||||
version = "0.19.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "545f52ad8a480732cc4290fd65dfe42952c8ae374fe581831ba15981fedf18a4"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.139"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
|
||||
|
||||
[[package]]
|
||||
name = "muldiv"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "956787520e75e9bd233246045d19f42fb73242759cc57fba9611d940ae96d4b0"
|
||||
|
||||
[[package]]
|
||||
name = "nom8"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae01545c9c7fc4486ab7debaf2aad7003ac19431791868fb2e8066df97fad2f8"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.45"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6f61fba1741ea2b3d6a1e3178721804bb716a68a6aeba1149b5d52e3d464ea66"
|
||||
|
||||
[[package]]
|
||||
name = "option-operations"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c26d27bb1aeab65138e4bf7666045169d1717febcc9ff870166be8348b223d0"
|
||||
dependencies = [
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d01a5bd0424d00070b0098dd17ebca6f961a959dead1dbcbbbc1d1cd8d3deeba"
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160"
|
||||
|
||||
[[package]]
|
||||
name = "pretty-hex"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
|
||||
dependencies = [
|
||||
"proc-macro-error-attr",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-error-attr"
|
||||
version = "1.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.51"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.152"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0"
|
||||
|
||||
[[package]]
|
||||
name = "streamer"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"gstreamer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "6.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2955b1fe31e1fa2fbd1976b71cc69a606d7d4da16f6de3333d0c92d51419aeff"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.18.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"nom8",
|
||||
"toml_datetime",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
||||
|
||||
[[package]]
|
||||
name = "winapi"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
|
||||
dependencies = [
|
||||
"winapi-i686-pc-windows-gnu",
|
||||
"winapi-x86_64-pc-windows-gnu",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-i686-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
|
@ -0,0 +1,10 @@
|
|||
[package]
|
||||
name = "streamer"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
gstreamer = "0.19.7"
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
use gstreamer::{format::ClockTime, prelude::*, MessageView};
|
||||
use std::{thread, time, time::Duration};
|
||||
|
||||
fn main() {
|
||||
gstreamer::init().unwrap();
|
||||
|
||||
let uri = "file:///home/savanni/Music/Lindsey%20Stirling/Artemis/01%20-%20Underground.mp3.mp3";
|
||||
let pipeline = gstreamer::parse_launch(&format!("playbin uri={}", uri)).unwrap();
|
||||
pipeline.set_state(gstreamer::State::Playing).unwrap();
|
||||
|
||||
let message_handler = {
|
||||
let pipeline = pipeline.clone();
|
||||
thread::spawn(move || {
|
||||
let bus = pipeline.bus().unwrap();
|
||||
for msg in bus.iter_timed(gstreamer::ClockTime::NONE) {
|
||||
match msg.view() {
|
||||
MessageView::Eos(_) => (),
|
||||
MessageView::Error(err) => {
|
||||
println!(
|
||||
"Error from {:?}: {} ({:?})",
|
||||
err.src().map(|s| s.path_string()),
|
||||
err.error(),
|
||||
err.debug()
|
||||
);
|
||||
}
|
||||
msg => println!("{:?}", msg),
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let query_handler = {
|
||||
let pipeline = pipeline.clone();
|
||||
thread::spawn(move || loop {
|
||||
let position: Option<ClockTime> = pipeline.query_position();
|
||||
let duration: Option<ClockTime> = pipeline.query_duration();
|
||||
println!("{:?} {:?}", position, duration);
|
||||
thread::sleep(Duration::from_millis(100));
|
||||
})
|
||||
};
|
||||
|
||||
message_handler.join();
|
||||
query_handler.join();
|
||||
|
||||
pipeline.set_state(gstreamer::State::Null).unwrap();
|
||||
}
|
18
readme.md
18
readme.md
|
@ -1 +1,19 @@
|
|||
# Luminescent Dreams Tools Monorepo
|
||||
|
||||
Add files in this repo are Copyright Savanni D'Gerinel, whether the copyright
|
||||
notice is present or not. All of the work in this repository, except where
|
||||
explicitely noted otherwise, is the sole work of Savanni D'Gerinel.
|
||||
|
||||
Future contributors will be noted in the CONTRIBUTORS file.
|
||||
|
||||
---
|
||||
|
||||
Copyright 2023, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
||||
|
||||
This file is part of the Luminescent Dreams Tools.
|
||||
|
||||
Luminescent Dreams Tools is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
|
||||
Luminescent Dreams Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with Lumeto. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
|
Loading…
Reference in New Issue