diff options
46 files changed, 1099 insertions, 476 deletions
@@ -4,7 +4,34 @@ resolver = "2" members = ["luz", "lampada", "stanza", "jid", "filamento"] [workspace.dependencies] +jid = { path = "jid" } +stanza = { path = "stanza" } +luz = { path = "luz" } +lampada = { path = "lampada" } tokio = { version = "1.42.0" } +peanuts = { version = "0.1.0", git = "https://bunny.garden/peanuts" } +thiserror = "2.0.11" +chrono = { version = "0.4.40" } +serde = { version = "1.0.219" } +tracing = { version = "0.1.40" } +uuid = { version = "1.13.1" } +futures = { version = "0.3.30" } + +# WASM dependencies + +tokio_with_wasm = "0.8.2" +web-sys = "0.3" +js-sys = "0.3" +wasm-bindgen = "0.2" +wasm-bindgen-futures = "0.4.50" + +# dev-dependencies + +tracing-wasm = "0.2.1" +wasm-bindgen-test = "0.3.0" +test-log = "0.2" +env_logger = "*" +tracing-subscriber = "0.3" [patch.crates-io] tokio_with_wasm = { path = "../tokio-with-wasm/tokio_with_wasm" } @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 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 Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are 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. + + 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. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + 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 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 work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero 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 your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + 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 AGPL, see +<https://www.gnu.org/licenses/>. @@ -101,13 +101,12 @@ - [ ] xep-0393: message styling - [ ] message routing NG -#### will prioritise new spec instead of: - - [ ] muc - [ ] xep-0045: muc - [ ] xep-0249: direct muc invitations - [ ] xep-0410: muc self-ping - [ ] xep-0402: pep native bookmarks + - [ ] xep-0421: occupant identifiers for semi-anonymous mucs - [ ] vcard legacy - [ ] xep-0292: vcard4 - [ ] xep-0398: user avatar compat diff --git a/filamento/Cargo.toml b/filamento/Cargo.toml index 90d2d73..7d7af0c 100644 --- a/filamento/Cargo.toml +++ b/filamento/Cargo.toml @@ -15,10 +15,10 @@ opfs = ["dep:web-sys"] reactive_stores = ["dep:reactive_stores"] [dependencies] -futures = "0.3.30" -lampada = { version = "0.1.0", path = "../lampada" } -thiserror = "2.0.11" -stanza = { version = "0.1.0", path = "../stanza", features = [ +futures = { workspace = true } +lampada = { workspace = true } +thiserror = { workspace = true } +stanza = { workspace = true, features = [ "rfc_6121", "xep_0203", "xep_0030", @@ -30,21 +30,21 @@ stanza = { version = "0.1.0", path = "../stanza", features = [ "xep_0084", ] } # TODO: re-export jid? -jid = { version = "0.1.0", path = "../jid", features = ["rusqlite"] } -uuid = { version = "1.13.1", features = ["v4"] } +jid = { workspace = true, features = ["rusqlite"] } +uuid = { workspace = true, features = ["v4"] } rusqlite = { git = "https://github.com/Spxg/rusqlite.git", branch = "wasm-demo", features = [ "uuid", "chrono", ] } -tracing = "0.1.41" -chrono = "0.4.40" +tracing = { workspace = true } +chrono = { workspace = true } +serde = { workspace = true, features = ["derive"], optional = true } sha2 = "0.10.8" sha3 = "0.10.8" base64 = "0.22.1" sha1 = "0.10.6" image = "0.25.6" hex = "0.4.3" -serde = { version = "1.0.219", features = ["derive"], optional = true } reactive_stores = { version = "0.2.2", optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -52,7 +52,7 @@ tokio = { workspace = true, features = ["sync", "time", "rt", "fs", "io-std"] } [target.'cfg(target_arch = "wasm32")'.dependencies] tokio = { workspace = true, features = ["sync", "time", "rt"] } -web-sys = { version = "0.3", features = [ +web-sys = { workspace = true, features = [ "FileSystemDirectoryHandle", "FileSystemWritableFileStream", "FileSystemGetDirectoryOptions", @@ -63,22 +63,20 @@ web-sys = { version = "0.3", features = [ "Window", "Navigator", ], optional = true } -jid = { version = "0.1.0", path = "../jid", features = ["rusqlite"] } -wasm-bindgen = "0.2" -wasm-bindgen-futures = "0.4" +wasm-bindgen = { workspace = true } +wasm-bindgen-futures = { workspace = true } rusqlite = { git = "https://github.com/Spxg/rusqlite.git", branch = "wasm-demo", features = [ "uuid", "chrono", "precompiled-wasm", ] } -tokio_with_wasm = { version = "0.8.2", features = ["sync", "time", "rt"] } +tokio_with_wasm = { workspace = true, features = ["sync", "time", "rt"] } [dev-dependencies] -tracing-subscriber = "0.3.19" -peanuts = { version = "0.1.0", git = "https://bunny.garden/peanuts" } -tracing-wasm = "0.2.1" -tokio_with_wasm = { version = "0.8.2", features = ["sync", "time", "rt"] } -wasm-bindgen-test = "0.3.0" +tracing-subscriber = { workspace = true } +peanuts = { workspace = true } +tracing-wasm = { workspace = true } +wasm-bindgen-test = { workspace = true } [[example]] name = "example" diff --git a/filamento/src/roster.rs b/filamento/src/roster.rs index 284e2b8..6b61e10 100644 --- a/filamento/src/roster.rs +++ b/filamento/src/roster.rs @@ -1,4 +1,4 @@ -use std::collections::HashSet; +use std::{collections::HashSet, fmt::Display}; use jid::JID; use rusqlite::{ @@ -27,15 +27,25 @@ pub struct Contact { } #[derive(Debug, Clone, PartialEq, Eq)] +/// Contact subscription state. pub enum Subscription { + /// No subscriptions. None, + /// Pending outgoing subscription request. PendingOut, + /// Pending incoming subscription request. PendingIn, + /// Pending incoming & pending outgoing subscription requests. PendingInPendingOut, + /// Subscribed to. OnlyOut, + /// Subscription from. OnlyIn, + /// Subscribed to & pending incoming subscription request. OutPendingIn, + /// Subscription from & pending outgoing subscription request. InPendingOut, + /// Buddy (subscriptions both ways). Buddy, // TODO: perhaps don't need, just emit event to remove contact // Remove, @@ -81,6 +91,30 @@ impl FromSql for Subscription { } } +impl Display for Subscription { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Subscription::None => write!(f, "No Subscriptions"), + Subscription::PendingOut => write!(f, "Pending Outgoing Subscription Request"), + Subscription::PendingIn => write!(f, "Pending Incoming Subscription Request"), + Subscription::PendingInPendingOut => write!( + f, + "Pending Incoming & Pending Outgoing Subscription Requests" + ), + Subscription::OnlyOut => write!(f, "Subscribed To"), + Subscription::OnlyIn => write!(f, "Subscription From"), + Subscription::OutPendingIn => { + write!(f, "Subscribed To & Pending Incoming Subscription Request") + } + Subscription::InPendingOut => write!( + f, + "Subscription From & Pending Outgoing Subscription Request" + ), + Subscription::Buddy => write!(f, "Buddy (Subscriptions Both Ways)"), + } + } +} + // none // > // >> diff --git a/jid/Cargo.toml b/jid/Cargo.toml index b8f4956..58d59a4 100644 --- a/jid/Cargo.toml +++ b/jid/Cargo.toml @@ -10,7 +10,7 @@ serde = ["dep:serde"] # sqlx = ["dep:sqlx"] [dependencies] -serde = { version = "1.0.219", features = ["derive"], optional = true } +serde = { workspace = true, features = ["derive"], optional = true } rusqlite = { git = "https://github.com/Spxg/rusqlite.git", optional = true, branch = "wasm-demo" } # sqlx = { version = "0.8.3", features = ["sqlite"], optional = true } # sqlx = { path = "../../remote/sqlx", features = ["sqlite"], optional = true } diff --git a/jid/src/lib.rs b/jid/src/lib.rs index 2499ca8..47ca497 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -1,7 +1,7 @@ use std::{borrow::Cow, error::Error, fmt::Display, str::FromStr}; -#[cfg(feature = "sqlx")] -use sqlx::Sqlite; +// #[cfg(feature = "sqlx")] +// use sqlx::Sqlite; #[derive(PartialEq, Debug, Clone, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -57,34 +57,34 @@ impl From<ParseError> for rusqlite::types::FromSqlError { } } -#[cfg(feature = "sqlx")] -impl sqlx::Type<Sqlite> for JID { - fn type_info() -> <Sqlite as sqlx::Database>::TypeInfo { - <&str as sqlx::Type<Sqlite>>::type_info() - } -} - -#[cfg(feature = "sqlx")] -impl sqlx::Decode<'_, Sqlite> for JID { - fn decode( - value: <Sqlite as sqlx::Database>::ValueRef<'_>, - ) -> Result<Self, sqlx::error::BoxDynError> { - let value = <&str as sqlx::Decode<Sqlite>>::decode(value)?; - - Ok(value.parse()?) - } -} - -#[cfg(feature = "sqlx")] -impl sqlx::Encode<'_, Sqlite> for JID { - fn encode_by_ref( - &self, - buf: &mut <Sqlite as sqlx::Database>::ArgumentBuffer<'_>, - ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> { - let jid = self.to_string(); - <String as sqlx::Encode<Sqlite>>::encode(jid, buf) - } -} +// #[cfg(feature = "sqlx")] +// impl sqlx::Type<Sqlite> for JID { +// fn type_info() -> <Sqlite as sqlx::Database>::TypeInfo { +// <&str as sqlx::Type<Sqlite>>::type_info() +// } +// } + +// #[cfg(feature = "sqlx")] +// impl sqlx::Decode<'_, Sqlite> for JID { +// fn decode( +// value: <Sqlite as sqlx::Database>::ValueRef<'_>, +// ) -> Result<Self, sqlx::error::BoxDynError> { +// let value = <&str as sqlx::Decode<Sqlite>>::decode(value)?; + +// Ok(value.parse()?) +// } +// } + +// #[cfg(feature = "sqlx")] +// impl sqlx::Encode<'_, Sqlite> for JID { +// fn encode_by_ref( +// &self, +// buf: &mut <Sqlite as sqlx::Database>::ArgumentBuffer<'_>, +// ) -> Result<sqlx::encode::IsNull, sqlx::error::BoxDynError> { +// let jid = self.to_string(); +// <String as sqlx::Encode<Sqlite>>::encode(jid, buf) +// } +// } #[derive(Debug, Clone)] pub enum JIDError { diff --git a/lampada/Cargo.toml b/lampada/Cargo.toml index 421360c..1937162 100644 --- a/lampada/Cargo.toml +++ b/lampada/Cargo.toml @@ -7,20 +7,20 @@ edition = "2021" serde = ["dep:serde"] [dependencies] -futures = "0.3.30" -luz = { version = "0.1.0", path = "../luz" } -peanuts = { version = "0.1.0", git = "https://bunny.garden/peanuts" } -jid = { version = "0.1.0", path = "../jid" } -stanza = { version = "0.1.0", path = "../stanza", features = ["xep_0203"] } -tracing = "0.1.41" -thiserror = "2.0.11" -serde = { version = "1.0.219", features = ["derive"], optional = true } +futures = { workspace = true } +luz = { workspace = true } +peanuts = { workspace = true } +jid = { workspace = true } +stanza = { workspace = true, features = ["xep_0203"] } +tracing = { workspace = true } +thiserror = { workspace = true } +serde = { workspace = true, features = ["derive"], optional = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] tokio = { workspace = true, features = ["macros", "sync"] } [target.'cfg(target_arch = "wasm32")'.dependencies] -tokio_with_wasm = { version = "0.8.2", features = [ +tokio_with_wasm = { workspace = true, features = [ "macros", "rt", "time", diff --git a/luz/Cargo.toml b/luz/Cargo.toml index 878132b..e9cccd9 100644 --- a/luz/Cargo.toml +++ b/luz/Cargo.toml @@ -10,39 +10,29 @@ crate-type = ["cdylib", "rlib"] # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -async-recursion = "1.0.4" -async-trait = "0.1.68" -lazy_static = "1.4.0" -uuid = { version = "1.13.1", features = ["v4"] } -# TODO: remove unneeded features and dependencies rsasl = { version = "2.0.1", default-features = false, features = [ "provider_base64", "plain", "config_builder", "scram-sha-1", ] } -tracing = "0.1.40" -try_map = "0.3.1" -stanza = { version = "0.1.0", path = "../stanza", features = ["xep_0156"] } -peanuts = { version = "0.1.0", git = "https://bunny.garden/peanuts" } -# peanuts = { version = "0.1.0", path = "../../peanuts" } -jid = { version = "0.1.0", path = "../jid" } -futures = "0.3.30" -take_mut = "0.2.2" -pin-project-lite = "0.2.15" -pin-project = "1.1.7" -thiserror = "2.0.11" +uuid = { workspace = true, features = ["v4"] } +tracing = { workspace = true } +stanza = { workspace = true, features = ["xep_0156"] } +peanuts = { workspace = true } +jid = { workspace = true } +thiserror = { workspace = true } [target.'cfg(target_arch = "wasm32")'.dependencies] -tokio = { workspace = true, features = ["macros", "rt", "time"] } -tokio_with_wasm = { version = "0.8.2", features = ["macros", "sync"] } -uuid = { version = "1.13.1", features = ["js", "v4"] } +tokio = { workspace = true, features = ["macros"] } +uuid = { workspace = true, features = ["js", "v4"] } +# TODO: check this getrandom = { version = "0.2.15", features = ["js"] } -stanza = { version = "0.1.0", path = "../stanza", features = [ +stanza = { workspace = true, features = [ "rfc_7395", "xep_0156", ] } -web-sys = { version = "0.3", features = [ +web-sys = { workspace = true, features = [ "Request", "WebSocket", "RequestInit", @@ -51,23 +41,24 @@ web-sys = { version = "0.3", features = [ "Response", "ErrorEvent", ] } -js-sys = "0.3" -wasm-bindgen = "0.2" -wasm-bindgen-futures = "0.4.50" +js-sys = { workspace = true } +wasm-bindgen = { workspace = true } +wasm-bindgen-futures = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -tokio = { workspace = true, features = ["io-util", "sync"] } +tokio = { workspace = true } tokio-native-tls = "0.3.1" trust-dns-resolver = "0.22.0" [dev-dependencies] -tracing-wasm = "0.2.1" -wasm-bindgen-test = "0.3.0" +# TODO: clean up dev dependencies and write tests +tracing-wasm = { workspace = true } +wasm-bindgen-test = { workspace = true } tokio = { workspace = true, features = ["macros", "rt", "time"] } -test-log = { version = "0.2", features = ["trace"] } -env_logger = "*" -tracing-subscriber = { version = "0.3", default-features = false, features = [ +test-log = { workspace = true, features = ["trace"] } +env_logger = { workspace = true } +tracing-subscriber = { workspace = true, default-features = false, features = [ "env-filter", "fmt", ] } -stanza = { version = "0.1.0", path = "../stanza", features = ["xep_0199"] } +stanza = { workspace = true, features = ["xep_0199"] } diff --git a/luz/src/client/ws.rs b/luz/src/client/ws.rs index ecb64cb..13c3cdf 100644 --- a/luz/src/client/ws.rs +++ b/luz/src/client/ws.rs @@ -5,8 +5,7 @@ use stanza::{ }; use crate::{ - connection::Ws, jabber_stream::bound_stream::BoundJabberStream, Connection, Error, - JabberStream, Result, JID, + jabber_stream::bound_stream::BoundJabberStream, Connection, Error, JabberStream, Result, JID, }; pub async fn connect_and_login( diff --git a/luz/src/connection/ws.rs b/luz/src/connection/ws.rs index caecf4a..e64a96e 100644 --- a/luz/src/connection/ws.rs +++ b/luz/src/connection/ws.rs @@ -1,5 +1,5 @@ use js_sys::Error; -use peanuts::{reader::ReadableString, Reader}; +use peanuts::{ReadableString, Reader}; use stanza::xep_0156::XRD; use tokio::sync::mpsc; use tracing::debug; @@ -91,7 +91,8 @@ impl Connection { } }) as Box<dyn FnMut()>); let (send, mut error_recv) = mpsc::unbounded_channel(); - let onerror = Closure::<dyn FnMut(_)>::new(Box::new(move |e: ErrorEvent| { + // TODO: get error event message + let onerror = Closure::<dyn FnMut(_)>::new(Box::new(move |_e: ErrorEvent| { // error will always be 1006, so doesn't matter. tracing::error!("connection error"); match send.send(()) { @@ -106,7 +107,7 @@ impl Connection { tokio::select! { _error = error_recv.recv() => { Err(ConnectionError::Connect(url.to_string()))? }, - Some(open) = open_recv.recv() => { }, + Some(_open) = open_recv.recv() => { }, else => { Err(ConnectionError::Connect(url.to_string()))? } } diff --git a/luz/src/jabber_stream.rs b/luz/src/jabber_stream.rs index 4332366..f77e6a9 100644 --- a/luz/src/jabber_stream.rs +++ b/luz/src/jabber_stream.rs @@ -8,9 +8,9 @@ use std::str::{self, FromStr}; use std::sync::Arc; use jid::JID; -use peanuts::element::IntoElement; +use peanuts::IntoElement; #[cfg(target_arch = "wasm32")] -use peanuts::reader::WebSocketOnMessageRead; +use peanuts::WebSocketOnMessageRead; use peanuts::{Reader, Writer}; use rsasl::prelude::{Mechname, SASLClient, SASLConfig}; use stanza::bind::{Bind, BindType, FullJidType, ResourceType}; @@ -19,8 +19,12 @@ use stanza::client::Stanza; #[cfg(target_arch = "wasm32")] use stanza::rfc_7395::Open; use stanza::sasl::{Auth, Challenge, Mechanisms, Response, ServerResponse}; +#[cfg(not(target_arch = "wasm32"))] use stanza::starttls::{Proceed, StartTls}; -use stanza::stream::{Features, Stream}; +use stanza::stream::Features; +#[cfg(not(target_arch = "wasm32"))] +use stanza::stream::Stream; +#[cfg(not(target_arch = "wasm32"))] use stanza::XML_VERSION; #[cfg(not(target_arch = "wasm32"))] use tokio_native_tls::native_tls::TlsConnector; @@ -31,8 +35,6 @@ use web_sys::{wasm_bindgen::JsCast, WebSocket}; use crate::connection::Connection; #[cfg(not(target_arch = "wasm32"))] use crate::connection::Tls; -#[cfg(target_arch = "wasm32")] -use crate::connection::Ws; use crate::error::Error; use crate::Result; diff --git a/luz/src/jabber_stream/tcp.rs b/luz/src/jabber_stream/tcp.rs index 77305e3..550c308 100644 --- a/luz/src/jabber_stream/tcp.rs +++ b/luz/src/jabber_stream/tcp.rs @@ -1,4 +1,4 @@ -use peanuts::loggable::Loggable; +use peanuts::Loggable; use peanuts::{Reader, Writer}; use tokio::io::{ReadHalf, WriteHalf}; diff --git a/luz/src/jabber_stream/ws.rs b/luz/src/jabber_stream/ws.rs index 35b6f60..72801e6 100644 --- a/luz/src/jabber_stream/ws.rs +++ b/luz/src/jabber_stream/ws.rs @@ -1,10 +1,9 @@ -use peanuts::loggable::Loggable; -use peanuts::reader::WebSocketOnMessageRead; +use peanuts::WebSocketOnMessageRead; use peanuts::{Reader, Writer}; use stanza::rfc_7395::Close; use web_sys::WebSocket; -use crate::{Connection, Result}; +use crate::Result; // open stream (streams started) #[derive(Debug)] @@ -43,7 +42,7 @@ impl JabberReader { impl JabberReader { pub async fn try_close(&mut self) -> Result<()> { - let close: Close = self.read().await?; + let _close: Close = self.read().await?; Ok(()) } } diff --git a/stanza/Cargo.toml b/stanza/Cargo.toml index 54577ff..884584a 100644 --- a/stanza/Cargo.toml +++ b/stanza/Cargo.toml @@ -4,10 +4,10 @@ version = "0.1.0" edition = "2021" [dependencies] -peanuts = { version = "0.1.0", git = "https://bunny.garden/peanuts" } -jid = { version = "0.1.0", path = "../jid" } -thiserror = "2.0.11" -chrono = { version = "0.4.40", optional = true } +peanuts = { workspace = true } +jid = { workspace = true } +thiserror = { workspace = true } +chrono = { workspace = true, optional = true } [features] rfc_6121 = [] diff --git a/stanza/src/bind.rs b/stanza/src/bind.rs index f72c510..3ce2246 100644 --- a/stanza/src/bind.rs +++ b/stanza/src/bind.rs @@ -1,8 +1,5 @@ use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-bind"; @@ -12,7 +9,7 @@ pub struct Bind { } impl FromElement for Bind { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("bind")?; element.check_namespace(XMLNS)?; @@ -23,7 +20,7 @@ impl FromElement for Bind { } impl IntoElement for Bind { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("bind", Some(XMLNS)).push_child_opt(self.r#type.clone()) } } @@ -35,7 +32,7 @@ pub enum BindType { } impl FromElement for BindType { - fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: peanuts::Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "resource") => { Ok(BindType::Resource(ResourceType::from_element(element)?)) @@ -47,7 +44,7 @@ impl FromElement for BindType { } impl IntoElement for BindType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { BindType::Resource(resource_type) => resource_type.builder(), BindType::Jid(full_jid_type) => full_jid_type.builder(), @@ -60,7 +57,7 @@ impl IntoElement for BindType { pub struct FullJidType(pub JID); impl FromElement for FullJidType { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("jid")?; element.check_namespace(XMLNS)?; @@ -71,7 +68,7 @@ impl FromElement for FullJidType { } impl IntoElement for FullJidType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("jid", Some(XMLNS)).push_text(self.0.clone()) } } @@ -81,7 +78,7 @@ impl IntoElement for FullJidType { pub struct ResourceType(pub String); impl FromElement for ResourceType { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("resource")?; element.check_namespace(XMLNS)?; @@ -92,7 +89,7 @@ impl FromElement for ResourceType { } impl IntoElement for ResourceType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("resource", Some(XMLNS)).push_text(self.0.clone()) } } diff --git a/stanza/src/client/error.rs b/stanza/src/client/error.rs index c4ab517..9cc85a9 100644 --- a/stanza/src/client/error.rs +++ b/stanza/src/client/error.rs @@ -1,8 +1,7 @@ use std::fmt::Display; use std::str::FromStr; -use peanuts::element::{FromElement, IntoElement}; -use peanuts::{DeserializeError, Element}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use thiserror::Error; use crate::stanza_error::Error as StanzaError; @@ -40,7 +39,7 @@ impl Display for Error { } impl FromElement for Error { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("error")?; element.check_name(XMLNS)?; @@ -59,7 +58,7 @@ impl FromElement for Error { } impl IntoElement for Error { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("error", Some(XMLNS)) .push_attribute_opt("by", self.by.clone()) .push_attribute("type", self.r#type) diff --git a/stanza/src/client/iq.rs b/stanza/src/client/iq.rs index a1d58f6..478530a 100644 --- a/stanza/src/client/iq.rs +++ b/stanza/src/client/iq.rs @@ -1,10 +1,7 @@ use std::str::FromStr; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, XML_NS, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement, XML_NS}; use crate::{ bind::{self, Bind}, @@ -60,7 +57,7 @@ pub enum Query { } impl FromElement for Query { - fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: peanuts::Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(bind::XMLNS), "bind") => Ok(Query::Bind(Bind::from_element(element)?)), #[cfg(feature = "xep_0199")] @@ -89,7 +86,7 @@ impl FromElement for Query { } impl IntoElement for Query { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { Query::Bind(bind) => bind.builder(), #[cfg(feature = "xep_0199")] @@ -111,7 +108,7 @@ impl IntoElement for Query { } impl FromElement for Iq { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("iq")?; element.check_namespace(XMLNS)?; @@ -136,7 +133,7 @@ impl FromElement for Iq { } impl IntoElement for Iq { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("iq", Some(XMLNS)) .push_attribute_opt("from", self.from.clone()) .push_attribute("id", self.id.clone()) diff --git a/stanza/src/client/message.rs b/stanza/src/client/message.rs index 78258ca..41761d2 100644 --- a/stanza/src/client/message.rs +++ b/stanza/src/client/message.rs @@ -1,10 +1,7 @@ use std::str::FromStr; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, XML_NS, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement, XML_NS}; #[cfg(feature = "xep_0060")] use crate::xep_0060::event::Event; @@ -40,7 +37,7 @@ pub struct Message { } impl FromElement for Message { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("message")?; element.check_namespace(XMLNS)?; @@ -88,7 +85,7 @@ impl FromElement for Message { } impl IntoElement for Message { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("message", Some(XMLNS)) .push_attribute_opt("from", self.from.clone()) .push_attribute_opt("id", self.id.clone()) @@ -166,7 +163,7 @@ pub struct Body { } impl FromElement for Body { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("body")?; element.check_namespace(XMLNS)?; @@ -178,7 +175,7 @@ impl FromElement for Body { } impl IntoElement for Body { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("body", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_text_opt(self.body.clone()) @@ -192,7 +189,7 @@ pub struct Subject { } impl FromElement for Subject { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("subject")?; element.check_namespace(XMLNS)?; @@ -204,7 +201,7 @@ impl FromElement for Subject { } impl IntoElement for Subject { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subject", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_text_opt(self.subject.clone()) @@ -218,7 +215,7 @@ pub struct Thread { } impl FromElement for Thread { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("thread")?; element.check_namespace(XMLNS)?; @@ -230,7 +227,7 @@ impl FromElement for Thread { } impl IntoElement for Thread { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("thread", Some(XMLNS)) .push_attribute_opt("parent", self.parent.clone()) .push_text_opt(self.thread.clone()) diff --git a/stanza/src/client/mod.rs b/stanza/src/client/mod.rs index a1b2de5..aca4fad 100644 --- a/stanza/src/client/mod.rs +++ b/stanza/src/client/mod.rs @@ -1,9 +1,7 @@ +use peanuts::{Content, ContentBuilder, DeserializeError, FromContent, FromElement, IntoContent}; + use iq::Iq; use message::Message; -use peanuts::{ - element::{Content, ContentBuilder, FromContent, FromElement, IntoContent}, - DeserializeError, -}; use presence::Presence; use super::stream::{self, Error as StreamError}; @@ -26,7 +24,7 @@ pub enum Stanza { } impl FromContent for Stanza { - fn from_content(content: Content) -> peanuts::element::DeserializeResult<Self> { + fn from_content(content: Content) -> peanuts::DeserializeResult<Self> { match content { Content::Element(element) => Ok(Stanza::from_element(element)?), Content::Text(_) => Ok(Stanza::OtherContent(content)), @@ -37,7 +35,7 @@ impl FromContent for Stanza { } impl FromElement for Stanza { - fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: peanuts::Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "message") => Ok(Stanza::Message(Message::from_element(element)?)), (Some(XMLNS), "presence") => Ok(Stanza::Presence(Presence::from_element(element)?)), @@ -51,7 +49,7 @@ impl FromElement for Stanza { } impl IntoContent for Stanza { - fn builder(&self) -> peanuts::element::ContentBuilder { + fn builder(&self) -> peanuts::ContentBuilder { match self { Stanza::Message(message) => <Message as IntoContent>::builder(message), Stanza::Presence(presence) => <Presence as IntoContent>::builder(presence), diff --git a/stanza/src/client/presence.rs b/stanza/src/client/presence.rs index a8c35d0..b0a0bc0 100644 --- a/stanza/src/client/presence.rs +++ b/stanza/src/client/presence.rs @@ -1,10 +1,7 @@ use std::str::FromStr; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, XML_NS, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement, XML_NS}; #[cfg(feature = "xep_0115")] use crate::xep_0115::C; @@ -41,7 +38,7 @@ pub struct Presence { } impl FromElement for Presence { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("presence")?; element.check_namespace(XMLNS)?; @@ -91,7 +88,7 @@ impl FromElement for Presence { } impl IntoElement for Presence { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("presence", Some(XMLNS)) .push_attribute_opt("from", self.from.clone()) .push_attribute_opt("id", self.id.clone()) @@ -174,7 +171,7 @@ pub enum Show { } impl FromElement for Show { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("show")?; element.check_namespace(XMLNS)?; @@ -197,7 +194,7 @@ impl FromStr for Show { } impl IntoElement for Show { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("show", Some(XMLNS)).push_text(*self) } } @@ -220,7 +217,7 @@ pub struct Status { } impl FromElement for Status { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("status")?; element.check_namespace(XMLNS)?; @@ -232,7 +229,7 @@ impl FromElement for Status { } impl IntoElement for Status { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("status", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_text(self.status.clone()) @@ -263,7 +260,7 @@ impl ToString for String1024 { pub struct Priority(pub i8); impl FromElement for Priority { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("priority")?; element.check_namespace(XMLNS)?; @@ -272,7 +269,7 @@ impl FromElement for Priority { } impl IntoElement for Priority { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("priority", Some(XMLNS)).push_text(self.0) } } diff --git a/stanza/src/rfc_7395.rs b/stanza/src/rfc_7395.rs index 23b9e5d..64d9f70 100644 --- a/stanza/src/rfc_7395.rs +++ b/stanza/src/rfc_7395.rs @@ -1,8 +1,5 @@ use jid::JID; -use peanuts::{ - element::{ElementBuilder, FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, ElementBuilder, FromElement, IntoElement}; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-framing"; diff --git a/stanza/src/roster.rs b/stanza/src/roster.rs index 0181193..14f65ef 100644 --- a/stanza/src/roster.rs +++ b/stanza/src/roster.rs @@ -1,10 +1,7 @@ use std::str::FromStr; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; pub const XMLNS: &str = "jabber:iq:roster"; @@ -15,7 +12,7 @@ pub struct Query { } impl FromElement for Query { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("query")?; element.check_namespace(XMLNS)?; @@ -27,7 +24,7 @@ impl FromElement for Query { } impl IntoElement for Query { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("query", Some(XMLNS)) .push_attribute_opt("ver", self.ver.clone()) .push_children(self.items.clone()) @@ -50,7 +47,7 @@ pub struct Item { } impl FromElement for Item { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("item")?; element.check_namespace(XMLNS)?; @@ -83,7 +80,7 @@ impl FromElement for Item { } impl IntoElement for Item { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("item", Some(XMLNS)) .push_attribute_opt("approved", self.approved) .push_attribute_opt( @@ -143,7 +140,7 @@ impl ToString for Subscription { pub struct Group(pub Option<String>); impl FromElement for Group { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("group")?; element.check_namespace(XMLNS)?; @@ -154,7 +151,7 @@ impl FromElement for Group { } impl IntoElement for Group { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("group", Some(XMLNS)).push_text_opt(self.0.clone()) } } diff --git a/stanza/src/sasl.rs b/stanza/src/sasl.rs index 598a91b..58aab84 100644 --- a/stanza/src/sasl.rs +++ b/stanza/src/sasl.rs @@ -1,9 +1,6 @@ use std::{fmt::Display, ops::Deref}; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use thiserror::Error; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-sasl"; @@ -14,7 +11,7 @@ pub struct Mechanisms { } impl FromElement for Mechanisms { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("mechanisms")?; element.check_namespace(XMLNS)?; let mechanisms: Vec<Mechanism> = element.pop_children()?; @@ -27,7 +24,7 @@ impl FromElement for Mechanisms { } impl IntoElement for Mechanisms { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("mechanisms", Some(XMLNS)).push_children( self.mechanisms .iter() @@ -40,7 +37,7 @@ impl IntoElement for Mechanisms { pub struct Mechanism(String); impl FromElement for Mechanism { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("mechanism")?; element.check_namespace(XMLNS)?; @@ -51,7 +48,7 @@ impl FromElement for Mechanism { } impl IntoElement for Mechanism { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("mechanism", Some(XMLNS)).push_text(self.0.clone()) } } @@ -71,7 +68,7 @@ pub struct Auth { } impl IntoElement for Auth { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("auth", Some(XMLNS)) .push_attribute("mechanism", self.mechanism.clone()) .push_text(self.sasl_data.clone()) @@ -90,7 +87,7 @@ impl Deref for Challenge { } impl FromElement for Challenge { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("challenge")?; element.check_namespace(XMLNS)?; @@ -112,7 +109,7 @@ impl Deref for Success { } impl FromElement for Success { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("success")?; element.check_namespace(XMLNS)?; @@ -130,7 +127,7 @@ pub enum ServerResponse { } impl FromElement for ServerResponse { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "challenge") => { Ok(ServerResponse::Challenge(Challenge::from_element(element)?)) @@ -164,7 +161,7 @@ impl Deref for Response { } impl IntoElement for Response { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("response", Some(XMLNS)).push_text(self.0.clone()) } } @@ -212,7 +209,7 @@ impl Display for Failure { } impl FromElement for Failure { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("failure")?; element.check_namespace(XMLNS)?; @@ -250,7 +247,7 @@ pub enum FailureType { } impl FromElement for FailureType { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "aborted") => Ok(FailureType::Aborted), (Some(XMLNS), "account-disabled") => Ok(FailureType::AccountDisabled), @@ -276,7 +273,7 @@ pub struct Text { } impl FromElement for Text { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("text")?; element.check_namespace(XMLNS)?; diff --git a/stanza/src/stanza_error.rs b/stanza/src/stanza_error.rs index 664a168..8fb862f 100644 --- a/stanza/src/stanza_error.rs +++ b/stanza/src/stanza_error.rs @@ -1,9 +1,6 @@ // https://datatracker.ietf.org/doc/html/rfc6120#appendix-A.8 -use peanuts::{ - element::{FromElement, IntoElement}, - Element, XML_NS, -}; +use peanuts::{Element, FromElement, IntoElement, XML_NS}; use thiserror::Error; #[cfg(feature = "xep_0060")] @@ -64,7 +61,7 @@ pub enum Error { } impl FromElement for Error { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { let error; match element.identify() { (Some(XMLNS), "bad-request") => error = Error::BadRequest, @@ -101,7 +98,7 @@ impl FromElement for Error { } impl IntoElement for Error { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { Error::BadRequest => Element::builder("bad-request", Some(XMLNS)), Error::Conflict => Element::builder("conflict", Some(XMLNS)), @@ -142,7 +139,7 @@ pub struct Text { } impl FromElement for Text { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("text")?; element.check_name(XMLNS)?; @@ -154,7 +151,7 @@ impl FromElement for Text { } impl IntoElement for Text { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("text", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_text_opt(self.text.clone()) diff --git a/stanza/src/starttls.rs b/stanza/src/starttls.rs index b0e0f0f..730c044 100644 --- a/stanza/src/starttls.rs +++ b/stanza/src/starttls.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-tls"; @@ -11,7 +8,7 @@ pub struct StartTls { } impl IntoElement for StartTls { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let mut builder = Element::builder("starttls", Some(XMLNS)); if self.required { @@ -42,7 +39,7 @@ impl FromElement for StartTls { pub struct Required; impl FromElement for Required { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("required")?; element.check_namespace(XMLNS)?; @@ -51,7 +48,7 @@ impl FromElement for Required { } impl IntoElement for Required { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("required", Some(XMLNS)) } } @@ -60,13 +57,13 @@ impl IntoElement for Required { pub struct Proceed; impl IntoElement for Proceed { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("proceed", Some(XMLNS)) } } impl FromElement for Proceed { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("proceed")?; element.check_namespace(XMLNS)?; @@ -77,13 +74,13 @@ impl FromElement for Proceed { pub struct Failure; impl IntoElement for Failure { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("failure", Some(XMLNS)) } } impl FromElement for Failure { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("failure")?; element.check_namespace(XMLNS)?; diff --git a/stanza/src/stream.rs b/stanza/src/stream.rs index eb07999..5be235a 100644 --- a/stanza/src/stream.rs +++ b/stanza/src/stream.rs @@ -1,8 +1,7 @@ use std::fmt::Display; use jid::JID; -use peanuts::element::{ElementBuilder, FromElement, IntoElement}; -use peanuts::Element; +use peanuts::{Element, ElementBuilder, FromElement, IntoElement}; use thiserror::Error; use crate::bind; @@ -165,7 +164,7 @@ impl IntoElement for Feature { } impl FromElement for Feature { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(starttls::XMLNS), "starttls") => { Ok(Feature::StartTls(StartTls::from_element(element)?)) @@ -198,7 +197,7 @@ impl Display for Error { } impl FromElement for Error { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("error")?; element.check_namespace(XMLNS)?; diff --git a/stanza/src/stream_error.rs b/stanza/src/stream_error.rs index 03d48eb..19ad1ae 100644 --- a/stanza/src/stream_error.rs +++ b/stanza/src/stream_error.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, XML_NS, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement, XML_NS}; use thiserror::Error; pub const XMLNS: &str = "urn:ietf:params:xml:ns:xmpp-streams"; @@ -61,7 +58,7 @@ pub enum Error { } impl FromElement for Error { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { let error; match element.identify() { (Some(XMLNS), "bad-format") => error = Error::BadFormat, @@ -99,7 +96,7 @@ impl FromElement for Error { } impl IntoElement for Error { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { Error::BadFormat => Element::builder("bad-format", Some(XMLNS)), Error::BadNamespacePrefix => Element::builder("bad-namespace-prefix", Some(XMLNS)), @@ -143,7 +140,7 @@ pub struct Text { } impl FromElement for Text { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("text")?; element.check_name(XMLNS)?; @@ -155,7 +152,7 @@ impl FromElement for Text { } impl IntoElement for Text { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("text", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_text_opt(self.text.clone()) diff --git a/stanza/src/xep_0004.rs b/stanza/src/xep_0004.rs index f929517..f6ff7a0 100644 --- a/stanza/src/xep_0004.rs +++ b/stanza/src/xep_0004.rs @@ -1,9 +1,6 @@ use std::str::FromStr; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; pub const XMLNS: &str = "jabber:x:data"; @@ -18,7 +15,7 @@ pub struct X { } impl FromElement for X { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("x")?; element.check_namespace(XMLNS)?; @@ -42,7 +39,7 @@ impl FromElement for X { } impl IntoElement for X { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("x", Some(XMLNS)) .push_attribute("type", self.r#type.clone()) .push_children(self.instructions.clone()) @@ -91,7 +88,7 @@ impl ToString for XType { pub struct Instructions(pub String); impl FromElement for Instructions { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("instructions")?; element.check_namespace(XMLNS)?; @@ -100,7 +97,7 @@ impl FromElement for Instructions { } impl IntoElement for Instructions { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("instructions", Some(XMLNS)).push_text(self.0.clone()) } } @@ -109,7 +106,7 @@ impl IntoElement for Instructions { pub struct Title(pub String); impl FromElement for Title { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("instructions")?; element.check_namespace(XMLNS)?; @@ -118,7 +115,7 @@ impl FromElement for Title { } impl IntoElement for Title { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("title", Some(XMLNS)).push_text(self.0.clone()) } } @@ -135,7 +132,7 @@ pub struct Field { } impl FromElement for Field { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("field")?; element.check_namespace(XMLNS)?; @@ -166,7 +163,7 @@ impl FromElement for Field { } impl IntoElement for Field { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let mut builder = Element::builder("field", Some(XMLNS)) .push_attribute_opt("label", self.label.clone()) .push_attribute_opt("type", self.r#type.clone()) @@ -239,7 +236,7 @@ impl ToString for FieldType { pub struct Desc(pub String); impl FromElement for Desc { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("desc")?; element.check_namespace(XMLNS)?; @@ -248,7 +245,7 @@ impl FromElement for Desc { } impl IntoElement for Desc { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("desc", Some(XMLNS)).push_text(self.0.clone()) } } @@ -257,7 +254,7 @@ impl IntoElement for Desc { pub struct Required; impl FromElement for Required { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("required")?; element.check_namespace(XMLNS)?; @@ -266,7 +263,7 @@ impl FromElement for Required { } impl IntoElement for Required { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("required", Some(XMLNS)) } } @@ -278,7 +275,7 @@ pub struct XOption { } impl FromElement for XOption { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("option")?; element.check_namespace(XMLNS)?; @@ -291,7 +288,7 @@ impl FromElement for XOption { } impl IntoElement for XOption { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("option", Some(XMLNS)) .push_attribute_opt("label", self.label.clone()) .push_child(self.value.clone()) @@ -302,7 +299,7 @@ impl IntoElement for XOption { pub struct Value(pub String); impl FromElement for Value { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("value")?; element.check_namespace(XMLNS)?; @@ -311,7 +308,7 @@ impl FromElement for Value { } impl IntoElement for Value { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("value", Some(XMLNS)).push_text(self.0.clone()) } } @@ -323,7 +320,7 @@ pub struct Reported { } impl FromElement for Reported { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("reported")?; element.check_namespace(XMLNS)?; @@ -334,7 +331,7 @@ impl FromElement for Reported { } impl IntoElement for Reported { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("reported", Some(XMLNS)).push_children(self.fields.clone()) } } @@ -345,7 +342,7 @@ pub struct Item { } impl FromElement for Item { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("item")?; element.check_namespace(XMLNS)?; @@ -356,7 +353,7 @@ impl FromElement for Item { } impl IntoElement for Item { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("item", Some(XMLNS)).push_children(self.fields.clone()) } } diff --git a/stanza/src/xep_0030/info.rs b/stanza/src/xep_0030/info.rs index 539934f..0344ccb 100644 --- a/stanza/src/xep_0030/info.rs +++ b/stanza/src/xep_0030/info.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, XML_NS, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement, XML_NS}; #[cfg(feature = "xep_0128")] use crate::xep_0004::X; @@ -22,7 +19,7 @@ pub struct Query { } impl FromElement for Query { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("query")?; element.check_namespace(XMLNS)?; @@ -50,7 +47,7 @@ impl FromElement for Query { } impl IntoElement for Query { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("query", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_children(self.features.clone()) @@ -78,7 +75,7 @@ pub struct Identity { } impl FromElement for Identity { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("identity")?; element.check_namespace(XMLNS)?; @@ -109,7 +106,7 @@ impl FromElement for Identity { } impl IntoElement for Identity { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("identity", Some(XMLNS)) .push_attribute("category", self.category.clone()) .push_attribute_opt("name", self.name.clone()) @@ -124,7 +121,7 @@ pub struct Feature { } impl FromElement for Feature { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("feature")?; element.check_namespace(XMLNS)?; @@ -135,7 +132,7 @@ impl FromElement for Feature { } impl IntoElement for Feature { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("feature", Some(XMLNS)).push_attribute("var", self.var.clone()) } } diff --git a/stanza/src/xep_0030/items.rs b/stanza/src/xep_0030/items.rs index 471f3e1..7707eac 100644 --- a/stanza/src/xep_0030/items.rs +++ b/stanza/src/xep_0030/items.rs @@ -1,8 +1,5 @@ use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; #[cfg(feature = "xep_0059")] use crate::xep_0059::Set; @@ -18,7 +15,7 @@ pub struct Query { } impl FromElement for Query { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("query")?; element.check_namespace(XMLNS)?; @@ -39,7 +36,7 @@ impl FromElement for Query { } impl IntoElement for Query { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("query", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_children(self.items.clone()); @@ -59,7 +56,7 @@ pub struct Item { } impl FromElement for Item { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("item")?; element.check_namespace(XMLNS)?; @@ -72,7 +69,7 @@ impl FromElement for Item { } impl IntoElement for Item { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("item", Some(XMLNS)) .push_attribute("jid", self.jid.clone()) .push_attribute_opt("name", self.name.clone()) diff --git a/stanza/src/xep_0059.rs b/stanza/src/xep_0059.rs index 01dbc6c..6490ad1 100644 --- a/stanza/src/xep_0059.rs +++ b/stanza/src/xep_0059.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "http://jabber.org/protocol/rsm"; @@ -17,7 +14,7 @@ pub struct Set { } impl FromElement for Set { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("set")?; element.check_namespace(XMLNS)?; @@ -42,7 +39,7 @@ impl FromElement for Set { } impl IntoElement for Set { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("set", Some(XMLNS)) .push_child_opt(self.after.clone()) .push_child_opt(self.before.clone()) @@ -58,7 +55,7 @@ impl IntoElement for Set { pub struct After(pub String); impl FromElement for After { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("after")?; element.check_namespace(XMLNS)?; @@ -67,7 +64,7 @@ impl FromElement for After { } impl IntoElement for After { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { // TODO: better way for push_text to work, empty string should be empty element no matter what let builder = Element::builder("after", Some(XMLNS)); @@ -83,7 +80,7 @@ impl IntoElement for After { pub struct Before(pub String); impl FromElement for Before { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("before")?; element.check_namespace(XMLNS)?; @@ -92,7 +89,7 @@ impl FromElement for Before { } impl IntoElement for Before { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { // TODO: better way for push_text to work, empty string should be empty element no matter what let builder = Element::builder("before", Some(XMLNS)); @@ -108,7 +105,7 @@ impl IntoElement for Before { pub struct Count(pub i32); impl FromElement for Count { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("count")?; element.check_namespace(XMLNS)?; @@ -117,7 +114,7 @@ impl FromElement for Count { } impl IntoElement for Count { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("count", Some(XMLNS)).push_text(self.0) } } @@ -126,7 +123,7 @@ impl IntoElement for Count { pub struct Index(pub i32); impl FromElement for Index { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("index")?; element.check_namespace(XMLNS)?; @@ -135,7 +132,7 @@ impl FromElement for Index { } impl IntoElement for Index { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("index", Some(XMLNS)).push_text(self.0) } } @@ -144,7 +141,7 @@ impl IntoElement for Index { pub struct Last(pub String); impl FromElement for Last { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("last")?; element.check_namespace(XMLNS)?; @@ -153,7 +150,7 @@ impl FromElement for Last { } impl IntoElement for Last { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { // TODO: better way for push_text to work, empty string should be empty element no matter what let builder = Element::builder("last", Some(XMLNS)); @@ -169,7 +166,7 @@ impl IntoElement for Last { pub struct Max(pub i32); impl FromElement for Max { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("max")?; element.check_namespace(XMLNS)?; @@ -178,7 +175,7 @@ impl FromElement for Max { } impl IntoElement for Max { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("max", Some(XMLNS)).push_text(self.0) } } @@ -190,7 +187,7 @@ pub struct First { } impl FromElement for First { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("first")?; element.check_namespace(XMLNS)?; @@ -203,7 +200,7 @@ impl FromElement for First { } impl IntoElement for First { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("first", Some(XMLNS)).push_attribute_opt("index", self.index); diff --git a/stanza/src/xep_0060/errors.rs b/stanza/src/xep_0060/errors.rs index e6817ac..6c6c530 100644 --- a/stanza/src/xep_0060/errors.rs +++ b/stanza/src/xep_0060/errors.rs @@ -1,9 +1,6 @@ use std::{fmt::Display, str::FromStr}; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use thiserror::Error; use crate::{client::error::ErrorType, stanza_error::Error as StanzaError}; @@ -121,7 +118,7 @@ impl Error { } impl FromElement for Error { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "closed-node") => Ok(Self::ClosedNode), (Some(XMLNS), "configuration-required") => Ok(Self::ConfigurationRequired), @@ -154,7 +151,7 @@ impl FromElement for Error { } impl IntoElement for Error { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { Error::ClosedNode => Element::builder("closed-node", Some(XMLNS)), Error::ConfigurationRequired => Element::builder("configuration-required", Some(XMLNS)), diff --git a/stanza/src/xep_0060/event.rs b/stanza/src/xep_0060/event.rs index 1be011d..3cb124b 100644 --- a/stanza/src/xep_0060/event.rs +++ b/stanza/src/xep_0060/event.rs @@ -2,10 +2,7 @@ use std::str::FromStr; use chrono::{DateTime, Utc}; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use crate::xep_0004::X; #[cfg(feature = "xep_0084")] @@ -26,7 +23,7 @@ pub enum Event { } impl FromElement for Event { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("event")?; element.check_namespace(XMLNS)?; @@ -49,7 +46,7 @@ impl FromElement for Event { } impl IntoElement for Event { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("event", Some(XMLNS)); match self { @@ -70,7 +67,7 @@ pub struct Collection { } impl FromElement for Collection { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("node")?; element.check_namespace(XMLNS)?; @@ -82,7 +79,7 @@ impl FromElement for Collection { } impl IntoElement for Collection { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("collection", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_child(self.r#type.clone()) @@ -96,7 +93,7 @@ pub enum CollectionType { } impl FromElement for CollectionType { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { (Some(XMLNS), "associate") => { Ok(CollectionType::Associate(Associate::from_element(element)?)) @@ -110,7 +107,7 @@ impl FromElement for CollectionType { } impl IntoElement for CollectionType { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { CollectionType::Associate(associate) => associate.builder(), CollectionType::Disassociate(disassociate) => disassociate.builder(), @@ -124,7 +121,7 @@ pub struct Associate { } impl FromElement for Associate { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("associate")?; element.check_namespace(XMLNS)?; @@ -135,7 +132,7 @@ impl FromElement for Associate { } impl IntoElement for Associate { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("associate", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -146,7 +143,7 @@ pub struct Disassociate { } impl FromElement for Disassociate { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("disassociate")?; element.check_namespace(XMLNS)?; @@ -157,7 +154,7 @@ impl FromElement for Disassociate { } impl IntoElement for Disassociate { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("disassociate", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -169,7 +166,7 @@ pub struct Configuration { } impl FromElement for Configuration { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("configuration")?; element.check_namespace(XMLNS)?; @@ -185,7 +182,7 @@ impl FromElement for Configuration { } impl IntoElement for Configuration { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("configuration", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_child_opt(self.configuration.clone()) @@ -199,7 +196,7 @@ pub struct Delete { } impl FromElement for Delete { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("delete")?; element.check_namespace(XMLNS)?; @@ -212,7 +209,7 @@ impl FromElement for Delete { } impl IntoElement for Delete { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("delete", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_child_opt(self.redirect.clone()) @@ -226,7 +223,7 @@ pub struct Items { } impl FromElement for Items { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("items")?; element.check_namespace(XMLNS)?; @@ -243,7 +240,7 @@ impl FromElement for Items { } impl IntoElement for Items { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("items", Some(XMLNS)).push_attribute("node", self.node.clone()); @@ -268,7 +265,7 @@ pub struct Item { } impl FromElement for Item { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("item")?; element.check_namespace(XMLNS)?; @@ -286,7 +283,7 @@ impl FromElement for Item { } impl IntoElement for Item { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("item", Some(XMLNS)) .push_attribute_opt("id", self.id.clone()) .push_attribute_opt("publisher", self.publisher.clone()) @@ -306,7 +303,7 @@ pub enum Content { } impl FromElement for Content { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { #[cfg(feature = "xep_0172")] (Some(xep_0172::XMLNS), "nick") => Ok(Content::Nick(Nick::from_element(element)?)), @@ -324,7 +321,7 @@ impl FromElement for Content { } impl IntoElement for Content { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { #[cfg(feature = "xep_0172")] Content::Nick(nick) => nick.builder(), @@ -343,7 +340,7 @@ pub struct Purge { } impl FromElement for Purge { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("purge")?; element.check_namespace(XMLNS)?; @@ -354,7 +351,7 @@ impl FromElement for Purge { } impl IntoElement for Purge { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("purge", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -365,7 +362,7 @@ pub struct Redirect { } impl FromElement for Redirect { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("redirect")?; element.check_namespace(XMLNS)?; @@ -376,7 +373,7 @@ impl FromElement for Redirect { } impl IntoElement for Redirect { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("redirect", Some(XMLNS)).push_attribute("uri", self.uri.clone()) } } @@ -387,7 +384,7 @@ pub struct Retract { } impl FromElement for Retract { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("retract")?; element.check_namespace(XMLNS)?; @@ -398,7 +395,7 @@ impl FromElement for Retract { } impl IntoElement for Retract { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("retract", Some(XMLNS)).push_attribute("id", self.id.clone()) } } @@ -413,7 +410,7 @@ pub struct Subscription { } impl FromElement for Subscription { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscription")?; element.check_namespace(XMLNS)?; @@ -434,7 +431,7 @@ impl FromElement for Subscription { } impl IntoElement for Subscription { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscription", Some(XMLNS)) .push_attribute_opt("expiry", self.expiry) .push_attribute("jid", self.jid.clone()) diff --git a/stanza/src/xep_0060/owner.rs b/stanza/src/xep_0060/owner.rs index 7cf4355..0617712 100644 --- a/stanza/src/xep_0060/owner.rs +++ b/stanza/src/xep_0060/owner.rs @@ -1,10 +1,7 @@ use std::str::FromStr; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use crate::xep_0004::X; @@ -21,7 +18,7 @@ pub enum Pubsub { } impl FromElement for Pubsub { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("pubsub")?; element.check_namespace(XMLNS)?; @@ -44,7 +41,7 @@ impl FromElement for Pubsub { } impl IntoElement for Pubsub { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("pubsub", Some(XMLNS)); match self { @@ -65,7 +62,7 @@ pub struct Affiliations { } impl FromElement for Affiliations { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("affiliations")?; element.check_namespace(XMLNS)?; @@ -78,7 +75,7 @@ impl FromElement for Affiliations { } impl IntoElement for Affiliations { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("affiliations", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_children(self.affiliations.clone()) @@ -92,7 +89,7 @@ pub struct Affiliation { } impl FromElement for Affiliation { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("affiliation")?; element.check_namespace(XMLNS)?; @@ -104,7 +101,7 @@ impl FromElement for Affiliation { } impl IntoElement for Affiliation { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("affiliation", Some(XMLNS)) .push_attribute("affiliation", self.affiliation.clone()) .push_attribute("jid", self.jid.clone()) @@ -158,7 +155,7 @@ pub struct Configure { } impl FromElement for Configure { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("configure")?; element.check_namespace(XMLNS)?; @@ -171,7 +168,7 @@ impl FromElement for Configure { } impl IntoElement for Configure { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("configure", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_child_opt(self.configure.clone()) @@ -182,7 +179,7 @@ impl IntoElement for Configure { pub struct Default(Option<X>); impl FromElement for Default { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("default")?; element.check_namespace(XMLNS)?; @@ -191,7 +188,7 @@ impl FromElement for Default { } impl IntoElement for Default { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("default", Some(XMLNS)).push_child_opt(self.0.clone()) } } @@ -203,7 +200,7 @@ pub struct Delete { } impl FromElement for Delete { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("delete")?; element.check_namespace(XMLNS)?; @@ -216,7 +213,7 @@ impl FromElement for Delete { } impl IntoElement for Delete { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("delete", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_child_opt(self.redirect.clone()) @@ -229,7 +226,7 @@ pub struct Purge { } impl FromElement for Purge { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("purge")?; element.check_namespace(XMLNS)?; @@ -240,7 +237,7 @@ impl FromElement for Purge { } impl IntoElement for Purge { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("purge", Some(XMLNS)).push_attribute("node", self.node.clone()) } } @@ -251,7 +248,7 @@ pub struct Redirect { } impl FromElement for Redirect { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("redirect")?; element.check_namespace(XMLNS)?; @@ -262,7 +259,7 @@ impl FromElement for Redirect { } impl IntoElement for Redirect { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("redirect", Some(XMLNS)).push_attribute("uri", self.uri.clone()) } } @@ -274,7 +271,7 @@ pub struct Subscriptions { } impl FromElement for Subscriptions { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscriptions")?; element.check_namespace(XMLNS)?; @@ -290,7 +287,7 @@ impl FromElement for Subscriptions { } impl IntoElement for Subscriptions { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscriptions", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_children(self.subscriptions.clone()) @@ -304,7 +301,7 @@ pub struct Subscription { } impl FromElement for Subscription { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscription")?; element.check_namespace(XMLNS)?; @@ -316,7 +313,7 @@ impl FromElement for Subscription { } impl IntoElement for Subscription { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscription", Some(XMLNS)) .push_attribute("subscription", self.subscription.clone()) .push_attribute("jid", self.jid.clone()) diff --git a/stanza/src/xep_0060/pubsub.rs b/stanza/src/xep_0060/pubsub.rs index 0f698dc..0416b78 100644 --- a/stanza/src/xep_0060/pubsub.rs +++ b/stanza/src/xep_0060/pubsub.rs @@ -1,10 +1,7 @@ use std::str::FromStr; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - DeserializeError, Element, -}; +use peanuts::{DeserializeError, Element, FromElement, IntoElement}; use crate::xep_0004::X; #[cfg(feature = "xep_0084")] @@ -30,7 +27,7 @@ pub enum Pubsub { } impl FromElement for Pubsub { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("pubsub")?; element.check_namespace(XMLNS)?; @@ -81,7 +78,7 @@ impl FromElement for Pubsub { } impl IntoElement for Pubsub { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let element = Element::builder("pubsub", Some(XMLNS)); match self { @@ -113,7 +110,7 @@ pub struct Affiliations { } impl FromElement for Affiliations { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("affiliations")?; element.check_namespace(XMLNS)?; @@ -126,7 +123,7 @@ impl FromElement for Affiliations { } impl IntoElement for Affiliations { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("affilations", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_children(self.affiliations.clone()) @@ -141,7 +138,7 @@ pub struct Affiliation { } impl FromElement for Affiliation { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("affiliation")?; element.check_namespace(XMLNS)?; @@ -153,7 +150,7 @@ impl FromElement for Affiliation { } impl IntoElement for Affiliation { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("affiliation", Some(XMLNS)) .push_attribute("affiliation", self.affiliation.clone()) .push_attribute("node", self.node.clone()) @@ -204,7 +201,7 @@ impl ToString for AffiliationType { pub struct Configure(Option<X>); impl FromElement for Configure { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("configure")?; element.check_namespace(XMLNS)?; @@ -213,7 +210,7 @@ impl FromElement for Configure { } impl IntoElement for Configure { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("configure", Some(XMLNS)).push_child_opt(self.0.clone()) } } @@ -224,7 +221,7 @@ pub struct Create { } impl FromElement for Create { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("create")?; element.check_namespace(XMLNS)?; @@ -235,7 +232,7 @@ impl FromElement for Create { } impl IntoElement for Create { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("create", Some(XMLNS)).push_attribute_opt("node", self.node.clone()) } } @@ -249,7 +246,7 @@ pub struct Default { } impl FromElement for Default { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("default")?; element.check_namespace(XMLNS)?; @@ -267,7 +264,7 @@ impl FromElement for Default { } impl IntoElement for Default { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("default", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_attribute_opt("type", self.r#type.clone()) @@ -312,7 +309,7 @@ pub struct Items { } impl FromElement for Items { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("items")?; element.check_namespace(XMLNS)?; @@ -332,7 +329,7 @@ impl FromElement for Items { } impl IntoElement for Items { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("items", Some(XMLNS)) .push_attribute_opt("max_items", self.max_items) .push_attribute("node", self.node.clone()) @@ -349,7 +346,7 @@ pub struct Item { } impl FromElement for Item { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("item")?; element.check_namespace(XMLNS)?; @@ -367,7 +364,7 @@ impl FromElement for Item { } impl IntoElement for Item { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("item", Some(XMLNS)) .push_attribute_opt("id", self.id.clone()) .push_attribute_opt("publisher", self.publisher.clone()) @@ -387,7 +384,7 @@ pub enum Content { } impl FromElement for Content { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { match element.identify() { #[cfg(feature = "xep_0172")] (Some(xep_0172::XMLNS), "nick") => Ok(Content::Nick(Nick::from_element(element)?)), @@ -405,7 +402,7 @@ impl FromElement for Content { } impl IntoElement for Content { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { match self { #[cfg(feature = "xep_0172")] Content::Nick(nick) => nick.builder(), @@ -427,7 +424,7 @@ pub struct Options { } impl FromElement for Options { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("options")?; element.check_namespace(XMLNS)?; @@ -447,7 +444,7 @@ impl FromElement for Options { } impl IntoElement for Options { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("options", Some(XMLNS)) .push_attribute("jid", self.jid.clone()) .push_attribute_opt("node", self.node.clone()) @@ -463,7 +460,7 @@ pub struct Publish { } impl FromElement for Publish { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("publish")?; element.check_namespace(XMLNS)?; @@ -476,7 +473,7 @@ impl FromElement for Publish { } impl IntoElement for Publish { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("publish", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_children(self.items.clone()) @@ -487,7 +484,7 @@ impl IntoElement for Publish { pub struct PublishOptions(pub Option<X>); impl FromElement for PublishOptions { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("publish-options")?; element.check_namespace(XMLNS)?; @@ -496,7 +493,7 @@ impl FromElement for PublishOptions { } impl IntoElement for PublishOptions { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("publish-options", Some(XMLNS)).push_child_opt(self.0.clone()) } } @@ -510,7 +507,7 @@ pub struct Retract { } impl FromElement for Retract { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("retract")?; element.check_namespace(XMLNS)?; @@ -528,7 +525,7 @@ impl FromElement for Retract { } impl IntoElement for Retract { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("retract", Some(XMLNS)) .push_attribute("node", self.node.clone()) .push_attribute_opt("notify", self.notify) @@ -543,7 +540,7 @@ pub struct SubscribeOptions { } impl FromElement for SubscribeOptions { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscribe-options")?; element.check_namespace(XMLNS)?; @@ -559,7 +556,7 @@ impl FromElement for SubscribeOptions { } impl IntoElement for SubscribeOptions { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("subscribe-options", Some(XMLNS)); if self.required { @@ -573,7 +570,7 @@ impl IntoElement for SubscribeOptions { pub struct Required; impl FromElement for Required { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("required")?; element.check_namespace(XMLNS)?; @@ -582,7 +579,7 @@ impl FromElement for Required { } impl IntoElement for Required { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("required", Some(XMLNS)) } } @@ -594,7 +591,7 @@ pub struct Subscribe { } impl FromElement for Subscribe { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscribe")?; element.check_namespace(XMLNS)?; @@ -606,7 +603,7 @@ impl FromElement for Subscribe { } impl IntoElement for Subscribe { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscribe", Some(XMLNS)) .push_attribute("jid", self.jid.clone()) .push_attribute_opt("node", self.node.clone()) @@ -620,7 +617,7 @@ pub struct Subscriptions { } impl FromElement for Subscriptions { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscriptions")?; element.check_namespace(XMLNS)?; @@ -636,7 +633,7 @@ impl FromElement for Subscriptions { } impl IntoElement for Subscriptions { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscriptions", Some(XMLNS)) .push_attribute_opt("node", self.node.clone()) .push_children(self.subscriptions.clone()) @@ -653,7 +650,7 @@ pub struct Subscription { } impl FromElement for Subscription { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("subscription")?; element.check_namespace(XMLNS)?; @@ -675,7 +672,7 @@ impl FromElement for Subscription { } impl IntoElement for Subscription { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("subscription", Some(XMLNS)) .push_attribute("jid", self.jid.clone()) .push_attribute_opt("node", self.node.clone()) @@ -727,7 +724,7 @@ pub struct Unsubscribe { } impl FromElement for Unsubscribe { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("unsubscribe")?; element.check_namespace(XMLNS)?; @@ -740,7 +737,7 @@ impl FromElement for Unsubscribe { } impl IntoElement for Unsubscribe { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("unsubscribe", Some(XMLNS)) .push_attribute("jid", self.jid.clone()) .push_attribute_opt("node", self.node.clone()) diff --git a/stanza/src/xep_0084/data.rs b/stanza/src/xep_0084/data.rs index 2a37df4..4b3223f 100644 --- a/stanza/src/xep_0084/data.rs +++ b/stanza/src/xep_0084/data.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:xmpp:avatar:data"; @@ -9,7 +6,7 @@ pub const XMLNS: &str = "urn:xmpp:avatar:data"; pub struct Data(pub String); impl FromElement for Data { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("data")?; element.check_namespace(XMLNS)?; @@ -18,7 +15,7 @@ impl FromElement for Data { } impl IntoElement for Data { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("data", Some(XMLNS)); if self.0.is_empty() { diff --git a/stanza/src/xep_0084/metadata.rs b/stanza/src/xep_0084/metadata.rs index c6a3fb4..e4edb2f 100644 --- a/stanza/src/xep_0084/metadata.rs +++ b/stanza/src/xep_0084/metadata.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:xmpp:avatar:metadata"; @@ -12,7 +9,7 @@ pub struct Metadata { } impl FromElement for Metadata { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("metadata")?; element.check_namespace(XMLNS)?; @@ -24,7 +21,7 @@ impl FromElement for Metadata { } impl IntoElement for Metadata { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("metadata", Some(XMLNS)) .push_children(self.info.clone()) .push_children(self.pointers.clone()) @@ -42,7 +39,7 @@ pub struct Info { } impl FromElement for Info { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("info")?; element.check_namespace(XMLNS)?; @@ -65,7 +62,7 @@ impl FromElement for Info { } impl IntoElement for Info { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("info", Some(XMLNS)) .push_attribute("bytes", self.bytes) .push_attribute_opt("height", self.height) @@ -80,7 +77,7 @@ impl IntoElement for Info { pub struct Pointer(pub PointerInner); impl FromElement for Pointer { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("pointer")?; element.check_namespace(XMLNS)?; @@ -89,7 +86,7 @@ impl FromElement for Pointer { } impl IntoElement for Pointer { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let _builder = Element::builder("pointer", Some(XMLNS)); match &self.0 { diff --git a/stanza/src/xep_0115.rs b/stanza/src/xep_0115.rs index 1c2ef69..1c9cd6f 100644 --- a/stanza/src/xep_0115.rs +++ b/stanza/src/xep_0115.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "http://jabber.org/protocol/caps"; @@ -14,7 +11,7 @@ pub struct C { } impl FromElement for C { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("c")?; element.check_namespace(XMLNS)?; @@ -33,7 +30,7 @@ impl FromElement for C { } impl IntoElement for C { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("c", Some(XMLNS)) .push_attribute_opt("ext", self.ext.clone()) .push_attribute("hash", self.hash.clone()) diff --git a/stanza/src/xep_0131.rs b/stanza/src/xep_0131.rs index 27fc962..68e6e96 100644 --- a/stanza/src/xep_0131.rs +++ b/stanza/src/xep_0131.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "http://jabber.org/protocol/disco#info"; @@ -9,7 +6,7 @@ pub const XMLNS: &str = "http://jabber.org/protocol/disco#info"; pub struct Headers(pub Vec<Header>); impl FromElement for Headers { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("headers")?; element.check_namespace(XMLNS)?; @@ -18,7 +15,7 @@ impl FromElement for Headers { } impl IntoElement for Headers { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("headers", Some(XMLNS)).push_children(self.0.clone()) } } @@ -30,7 +27,7 @@ pub struct Header { } impl FromElement for Header { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("header")?; element.check_namespace(XMLNS)?; @@ -43,7 +40,7 @@ impl FromElement for Header { } impl IntoElement for Header { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("header", Some(XMLNS)).push_attribute("name", self.name.clone()); diff --git a/stanza/src/xep_0156.rs b/stanza/src/xep_0156.rs index ad22f7e..bf6eac5 100644 --- a/stanza/src/xep_0156.rs +++ b/stanza/src/xep_0156.rs @@ -1,8 +1,5 @@ use chrono::{DateTime, Utc}; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, XML_NS, -}; +use peanuts::{Element, FromElement, IntoElement, XML_NS}; pub const XMLNS: &str = "http://docs.oasis-open.org/ns/xri/xrd-1.0"; pub const SIGNATURE_XMLNS: &str = "http://www.w3.org/2000/09/xmldsig#"; @@ -19,7 +16,7 @@ pub struct XRD { } impl FromElement for XRD { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("XRD")?; element.check_namespace(XMLNS)?; @@ -45,7 +42,7 @@ impl FromElement for XRD { } impl IntoElement for XRD { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("XRD", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "id", self.id.clone()) .push_child_opt(self.expires.clone()) @@ -61,7 +58,7 @@ impl IntoElement for XRD { pub struct Expires(pub DateTime<Utc>); impl FromElement for Expires { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Expires")?; element.check_namespace(XMLNS)?; @@ -70,7 +67,7 @@ impl FromElement for Expires { } impl IntoElement for Expires { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Expires", Some(XMLNS)) .push_text(self.0.format("%C%y-%m-%dT%H:%M:%S%.3f%:z")) } @@ -81,7 +78,7 @@ impl IntoElement for Expires { pub struct Subject(pub String); impl FromElement for Subject { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Subject")?; element.check_namespace(XMLNS)?; @@ -90,7 +87,7 @@ impl FromElement for Subject { } impl IntoElement for Subject { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Subject", Some(XMLNS)).push_text(self.0.clone()) } } @@ -100,7 +97,7 @@ impl IntoElement for Subject { pub struct Alias(pub String); impl FromElement for Alias { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Alias")?; element.check_namespace(XMLNS)?; @@ -109,7 +106,7 @@ impl FromElement for Alias { } impl IntoElement for Alias { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Alias", Some(XMLNS)).push_text(self.0.clone()) } } @@ -121,7 +118,7 @@ pub struct Property { } impl FromElement for Property { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Property")?; element.check_name(XMLNS)?; @@ -134,7 +131,7 @@ impl FromElement for Property { } impl IntoElement for Property { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Property", Some(XMLNS)) .push_attribute("type", self.r#type.clone()) .push_text_opt(self.property.clone()) @@ -152,7 +149,7 @@ pub struct Link { } impl FromElement for Link { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Link")?; element.check_namespace(XMLNS)?; @@ -176,7 +173,7 @@ impl FromElement for Link { } impl IntoElement for Link { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Link", Some(XMLNS)) .push_attribute_opt("rel", self.rel.clone()) .push_attribute_opt("type", self.r#type.clone()) @@ -194,7 +191,7 @@ pub struct Title { } impl FromElement for Title { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Title")?; element.check_namespace(XMLNS)?; @@ -207,7 +204,7 @@ impl FromElement for Title { } impl IntoElement for Title { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Title", Some(XMLNS)) .push_attribute_opt_namespaced(XML_NS, "lang", self.lang.clone()) .push_text(self.title.clone()) @@ -218,7 +215,7 @@ impl IntoElement for Title { pub struct Signature; impl FromElement for Signature { - fn from_element(element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("Signature")?; element.check_namespace(SIGNATURE_XMLNS)?; @@ -227,7 +224,7 @@ impl FromElement for Signature { } impl IntoElement for Signature { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("Signature", Some(SIGNATURE_XMLNS)) } } diff --git a/stanza/src/xep_0172.rs b/stanza/src/xep_0172.rs index 1c24200..54846b8 100644 --- a/stanza/src/xep_0172.rs +++ b/stanza/src/xep_0172.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "http://jabber.org/protocol/nick"; @@ -9,7 +6,7 @@ pub const XMLNS: &str = "http://jabber.org/protocol/nick"; pub struct Nick(pub String); impl FromElement for Nick { - fn from_element(mut element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("nick")?; element.check_namespace(XMLNS)?; @@ -18,7 +15,7 @@ impl FromElement for Nick { } impl IntoElement for Nick { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("nick", Some(XMLNS)); if self.0.is_empty() { diff --git a/stanza/src/xep_0199.rs b/stanza/src/xep_0199.rs index 9605721..2ab3a86 100644 --- a/stanza/src/xep_0199.rs +++ b/stanza/src/xep_0199.rs @@ -1,7 +1,4 @@ -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:xmpp:ping"; @@ -9,7 +6,7 @@ pub const XMLNS: &str = "urn:xmpp:ping"; pub struct Ping; impl FromElement for Ping { - fn from_element(element: peanuts::Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(element: peanuts::Element) -> peanuts::DeserializeResult<Self> { element.check_name("ping")?; element.check_namespace(XMLNS)?; @@ -20,7 +17,7 @@ impl FromElement for Ping { } impl IntoElement for Ping { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("ping", Some(XMLNS)) } } diff --git a/stanza/src/xep_0203.rs b/stanza/src/xep_0203.rs index b8f9239..41ff196 100644 --- a/stanza/src/xep_0203.rs +++ b/stanza/src/xep_0203.rs @@ -1,9 +1,6 @@ use chrono::{DateTime, Utc}; use jid::JID; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:xmpp:delay"; @@ -14,7 +11,7 @@ pub struct Delay { } impl FromElement for Delay { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("delay")?; element.check_namespace(XMLNS)?; @@ -26,7 +23,7 @@ impl FromElement for Delay { } impl IntoElement for Delay { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("delay", Some(XMLNS)) .push_attribute_opt("from", self.from.clone()) .push_attribute("stamp", self.stamp.format("%C%y-%m-%dT%H:%M:%S%.3f%:z")) diff --git a/stanza/src/xep_0300.rs b/stanza/src/xep_0300.rs index 71a2c36..f522f1c 100644 --- a/stanza/src/xep_0300.rs +++ b/stanza/src/xep_0300.rs @@ -1,9 +1,6 @@ use std::{convert::Infallible, str::FromStr}; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:xmpp:hashes:2"; @@ -14,7 +11,7 @@ pub struct Hash { } impl FromElement for Hash { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("hash")?; element.check_namespace(XMLNS)?; @@ -27,7 +24,7 @@ impl FromElement for Hash { } impl IntoElement for Hash { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { let builder = Element::builder("hash", Some(XMLNS)).push_attribute("algo", self.algo.clone()); @@ -46,7 +43,7 @@ pub struct HashUsed { } impl FromElement for HashUsed { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("hash-used")?; element.check_namespace(XMLNS)?; @@ -57,7 +54,7 @@ impl FromElement for HashUsed { } impl IntoElement for HashUsed { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("hash-used", Some(XMLNS)).push_attribute("algo", self.algo.clone()) } } diff --git a/stanza/src/xep_0390.rs b/stanza/src/xep_0390.rs index bcd331d..1a079c2 100644 --- a/stanza/src/xep_0390.rs +++ b/stanza/src/xep_0390.rs @@ -1,8 +1,5 @@ use crate::xep_0300::Hash; -use peanuts::{ - element::{FromElement, IntoElement}, - Element, -}; +use peanuts::{Element, FromElement, IntoElement}; pub const XMLNS: &str = "urn:xmpp:caps"; @@ -11,7 +8,7 @@ pub const XMLNS: &str = "urn:xmpp:caps"; pub struct C(pub Vec<Hash>); impl FromElement for C { - fn from_element(mut element: Element) -> peanuts::element::DeserializeResult<Self> { + fn from_element(mut element: Element) -> peanuts::DeserializeResult<Self> { element.check_name("c")?; element.check_namespace(XMLNS)?; @@ -20,7 +17,7 @@ impl FromElement for C { } impl IntoElement for C { - fn builder(&self) -> peanuts::element::ElementBuilder { + fn builder(&self) -> peanuts::ElementBuilder { Element::builder("c", Some(XMLNS)).push_children(self.0.clone()) } } |