Since Amazon (suspiciously) won’t let me review this book that I purchased, I will review it here. I would have been kinder on amazon, but blocking reviews is a dirty tactic for a publisher.
This book has a great deal of useful information in it, *BUT*. I have 40 years programming experience from VAX assembly through C# and .NET 6. I have read dozens of programming books and rarely find so many segments that are close to incomprehensible to me after the first or even second pass, both in code and in text. Part of this is rust itself, which seems to use every possible special character in some strange new way, even in combinations (but does not implement the ++ operator, just to offend C++ programmers I think) and has constructs that are likely unfamiliar to a majority of modern programmers. You need to make some investment to understand these things, and that really needs to come before anything else. Other rust books are certainly easier to grok and therefore likely better starting points for anyone not seasoned in C/C++, which are also irrelevant to me, but which the book mentions often, and for which it even provides out-of-context code samples that I cannot understand without additional research.
The authors are clearly trying to demonstrate their individual experience and intelligence rather than educating their audience completely or properly. These are exactly the kind of programmers that make bad development team members – their code may be efficient, but only they can follow and maintain it, and given the level of documentation for the code samples in the book…
Most programmers have nothing to do with complex numbers and fractals, so these problem domains are confusing and irrelevant. Here’s a very closely-guarded secret: for the last 30 years, most programmers have *not* been mathematicians. Honestly, I might fail trig if I tried it again, not because it is hard, but because it is completely irrelevant and not interesting to me and serves me no purpose, and the computer is there to answer those questions anyway. That’s how we build knowledge scaffolding, by focusing on the concepts and leveraging what already exists rather than re-inventing everything. Doesn’t mean I don’t understand trig; it means I don’t do the calculations by hand or with code, as someone wrote trusted libraries for that decades ago.
Nowadays, we are mostly web developers, and there is almost no mention of anything web in this book – barely touches on JSON, HTTP server, HTTP client, or anything else likely to be relevant to a majority of programmers (though rust includes none of this in its standard libraries anyway). It’s almost like a theory book. If you want to target the majority of developers, you have to know who they are and meet them where they are. Trying to convince C/C++ programmers (many of whom know the Linux kernel cannot be rewritten in safe rust and are just waiting for rust to have a huge public security problem, whether from the compiler or the risky tooling combined with critical unregulated third-party library diaspora disaster and such, or otherwise) to switch to rust seems like a non-starter.
At the same time, the authors and their editors were *not* smart enough to find several errors in the text and the code, some of which seem to be failures to update from a previous edition. The result is that, unless you are 100% going into rust and plan to read this book a few times and notate the authors’ errors and omissions, many of the explanations for code examples will seem incomplete and leave out critical details that would help you to understand them. You will almost certainly need to supplant this book with additional books and other resources, which are a better place to start with rust. Definitely not written by educators.
This is not the kind of book that you pick up when you need an answer without having read the entire thing first, at least once. It’s not a beginner book, it’s not a reference…it’s the authors showing off.
So in summary, this book is useful, but it is also insulting, frustrating, and confusing. Additionally, much of its content is likely irrelevant to the majority of its readers. At least for the section on modules, they didn’t use the front of restaurant/back of restaurant paradigm from the real rust book, which also has no relation to any problem domain that I have ever seen. That is about the only section of the default rust book that I found worse than this one.
BTW, I am in no way implying that my book was any better; I admit that it was far worse. I have some understanding of how hard it is to publish a technical book like this, so I forgive the authors somewhat (not for the arrogant and intentionally confusing bits). Relevant examples and a little more explanation of the code is what the readers were likely after, and would have greatly increased the value of this book, which missed the mark for me.
Update: This popped up on amazon the next day, immediately after I had tagged one of the authors on LinkedIn with this review. Most of the reviews of the previous edition are positive, but I don’t know how much we can trust amazon reviews anyway. I found one review that seemed to agree with some of my perspectives. Maybe I am just not smart enough for rust or this book.
This blog post links to some primary resources for learning the rust programming language. If you know of anything that should be in this list, please comment on this blog post.
While many of the symbols used in rust source code are like those used in other languages, some languages do not use those symbols or use them differently. This blog post provides short explanations for rust programming symbols that may not be used or may be used differently in other languages. Again, I am just learning rust, and although this might not be completely technically accurate or use perfect terminology, it could assist casual rust readers. Real developers should of course consult the documentation for a more thorough explanation and greater understanding of not only the symbols, but the concepts that they represent.
What follows are simplified explanations of my understanding of some common symbols in rust source code.
& Borrows a reference, which has to do with managing the lifetime of its data, often when passing things to functions.
‘ Designates lifetime requirements explicitly, typically to help the compiler validate arguments to functions.
! In addition to being the negation (not) operator, following what appears to be a function name, ! indicates a macro, such as println!(), which works something like a function defined with the fn token. This can be particularly confusing in statements such as the following, which, especially considering that rust conditionals do not require parentheses, one might assume negates the condition check: pub fn is_windows() -> bool { cfg!(target_os = “windows”)}.
_ Catchall condition for match expressions, which are something like big switch statements, but much better.
* Dereference or raw pointer. I try not to do this.
:: This is typically a scope resolution operator in rust paths, such as such as std::io, which are similar to namespaces and typically correspond to file paths, often in external packages.
|| With contents, this can indicate a closure.
() Without a name and with contents, these characters () symbol generally seems to indicate a tuple. After a name, they can indicate an enumeration, which in rust is a construct that can contain a value within those parentheses. An empty pair of parentheses can also basically indicate a null set, which seems similar to the Some() and None enumeration pattern.
? Following certain statements, this can propagate an error up the calls stack. This allows exception management at a higher level without try/catch blocks and for local code to proceed as if no error had occurred.
+ Used to indicate constraints in type conditions.
Note that there appears to be no ++ operator in rust.
This blog post contains perspectives on similarities and differences between the rust programming language and the C# programming language for .NET. This post focusses on command line and background processes and does not consider native user interface technologies for Windows or Linux, although for now at least, C# is almost certainly more appropriate for Windows developers and rust may be more appropriate for Linux UI developers. I am not a professional programmer; this post provides my opinions based on about 20 years of experience with C# and a few weeks with rust.
This post is actually on a different blog of mine about .NET.
This blog post describes what could be an extremely dangerous issue with the default configuration of cargo, the build tool for rust programs. Apparently, the cargo clean command tries to remove everything from its build directory, which defaults to /tmp.
[2021-06-25 13:59:12]:jw@HAL9000-6WQ9TQ2:/mnt/c/temp/cscdprox
$ cargo clean
error: could not remove build directory
Caused by:
failed to remove file `/tmp/rider/jetbrains-toolbox-1.20.8804/jetbrains-toolbox`
Caused by:
Permission denied (os error 13)
Luckily, I use /tmp for things that are truly temporary, generally on an instantaneous basis, and some things in /tmp were somehow owned by root, which raised the alert. I do not know what damage this may have done to my system, but honestly I subsequently had issues with WSL that a reboot (luckily) resolved. And Linux programmers chuckle at Windows…
One solution is to specify the target directory on every command path. A safer backup would be to update the target-dir setting in the ~/.cargo/config file from /tmp to something like /tmp/thatsbad A double-failsafe could be to set the CARGO_TARGET_DIR environment variable to something like /tmp/isthatworse.
I figured out why my the rustfmt commands in the build script for my rust program were reformatting certain .rs source code files repeatedly, including one that I was explicitly excluding from the command line. I was trying to pass each file to the rustfmt command individually, excluding the one that I need to format differently because it contains long lines of code.
As it turns out, the rustfmt command formats the file(s) specified on the command line as well as any files that those files reference, so it is not necessary to call rustfmt repeatedly or to pass all of the file paths on the command line. I do not think it is possible to exclude referenced files from formatting, but you can reformat those files afterwards.
To format all the files in a project requires a single short command.
This blog post is the eighth in a series that describes the structure of the wink command line program that I have written in rust and that I use to invoke other Windows and Linux programs from bash and Windows shells under Windows Subsystem for Linux. This post describes the wince Unix sh shell script that I use to build, test, and install the wink program.
/wince: Unix sh script uses cargo to manage building wink for Windows and Unix.
#!/bin/sh -x
Use the /bin/sh interpreter and echo invoked commands.
clear
Clear the screen to make it easier to fine the latest output from this wince command.
export RUST_BACKTRACE=full # or 1
Setting the RUST_BACKTRACE environment variable to 1 or full causes rust executables to generate more output.
rustup update
Update the rust tools.
projdir=/mnt/c/temp/wink # directory containing cargo.toml
winbld='C:\temp\wink.build' # Windows path to directory for building Windows binary
linstall=~/bin # WSL binary install path
cd $projdir # avoid specifying project path for all commands
Specify some paths. It would probably be appropriate to specify $projdir on all command lines, but most command lines are long enough already, and it is redundant.
The cargo check command is faster than compiling, so a quick way to identify errors before continuing. For unknown reasons, sometimes it fails even though the code is good, but generally works the first or second time. The redirects and tee allow capturing stdout from the command into the result variable.
Cargo build builds any required binaries for the package. I do not use debug build features; I build releases and test in production, which is my desktop.
cargo doc -v --target-dir $linbld # --open to open in browser
The cargo doc command builds HTML documentation from comments in the code.
ls -l ${linbld}/release/wink # show WSL binary file size and build date
The binary seems huge relative to the code volume, and not much different from the debug binary, but performs well.
Install the Linux binary. To be honest, WSL could call the Windows binary from a bash shell, or wink could call the Windows binary from a bash shell, or a Windows shell could call bash.exe to invoke the Linux binary of wink, which would be best for putting a finger in Microsoftβs eye for not having migrated Windows to a Linux kernel after Windows NT. It is always better to invoke a binary, or even call wsl.exe or bash.exe, or when needed even wt.exe, rather than cmd.exe or explorer.exe.
Use the Windows version of cargo to build the Windows executable.
`wslpath ${winbld}`/release/wink.exe -ep > ${linbld}/doc/wink/wink.json # export JSON
cp ${linbld}/doc/wink/wink.json . # copy JSON to project root for github
Use the Windows executable to export JSON, partly as a test, but also for github.
ls -l ${linbld}/doc/wink/wink.json # show JSON file size and touch time
Show JSON file size and touch time.
path=`cmd.exe /c echo %USERPROFILE% | sed -e 's/\r//g'` # install Windows binary to this directory in %PATH%
path=`wslpath $path | sed -e 's/\r//g'`/AppData/Local/Microsoft/WindowsApps
cp ${lwinbld}/release/wink.exe $path # install Windows binary
Install the Windows binary for cmd.exe and powershell.exe, which I only use for testing.
set +x
Do not echo shell commands.
${linstall}/wink $@ # run Linux build with parameters supplied on command line
Run the Linux binary.
cp /mnt/c/temp/wink/wince $linstall # install any updates to this wince shell script
Install any updates to this script (this line can result in error messages that are usually irrelevant).
cd - > /dev/null # revert to the previous directory
exit 0
Then you just run a command like this and enter the matrix for about 20 seconds.
time wince -vepd word ; time wink -vepd word
output from winceoutput from running time wince -vepd word ; time wink -vepd word
Here is the current complete output from wink help. Yes, I see many typos in all of this too.
[2021-06-24 22:08:37]:jw@HAL9000-6WQ9TQ2:/mnt/c/temp/wink
$ wink -help
-----------------------------------------------------------------------------
wink : access Windows and WSL features : Help requested by -help
-----------------------------------------------------------------------------
wink : invoked as : wink -help
-----------------------------------------------------------------------------
wink EXP explorer.exe
-----------------------------------------------------------------------------
wink EXP <file.ext> Set/open default application for extension
wink EXP <shell:sendto> Invoke command code (replace <shell:sendto>)
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
wink CMD cmd.exe /c
-----------------------------------------------------------------------------
wink CMD <cmd> [args] Invoke Windows console command line
wink CMD echo %PATH% Display Windows environment variable
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
wink BASH bash.exe -c
-----------------------------------------------------------------------------
wink BASH /path [args] Invoke shell command line
wink BASH echo '$USER' Display WSL environment variable
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
wink CODE [args] See command code tables below
-----------------------------------------------------------------------------
Applications
-----------------------------------------------------------------------------
7Z 7-Zip compressed file manager
AUDACITY Audacity audio file editor
DESKPINS DeskPins
DOTPEEK JetBrains dotPeek .NET disassembler
EDGE Microsoft Edge
EMAIL Default email program
FIREFOX Mozilla Firefox browser
FLP Agent Ransack file search tool
FOOBAR Foobar2000 music player
IRFAN IfranView Media Viewer
KILLSLAK Kill Zoom
KILLZOOM Kill Zoom
LINQPAD LINQPad for C#
MDP MarkdownPad2
POSTMAN Postman
RANSACK Mozilla Thunderbird email client
RIDER JetBrains Rider IDE
SKYPE Skype
SLACK Slack
SPOTIFY Spotify
SUB Sublime Text Editor
TB Mozilla Thunderbird email client
TEAMS Microsoft Teams
TRACKME Microsoft Edge
VLC VLC Media Player
VS Microsoft Visual Studio
VSCODE Microsoft Visual Studio Code
WINMERGE WinMerge file and directory comparison tool
ZOOM Zoom
Ease of Access
-----------------------------------------------------------------------------
CAPTIONS Ease of Access closed captioning settings
EAAUDIO Ease of Access audio settings
EACOLFLT Ease of Access color filter
EADISP Ease of Access display settings
EAEYEC Ease of Access eye control
EAHIGHC Ease of Access high contrast
EAKEYB Ease of Access keyboard settings
EAMAG Ease of Access magnifier
EAMOUSE Ease of Access mouse settings
EANAR Ease of Access narrator settings
EASE Ease of Access Settings
EASPEECH Ease of Access speech recognition settings
EATCUR Ease of Access text cursor settings
Features
-----------------------------------------------------------------------------
DEFAULTS Default Programs
DELIVOPT Microsoft Updates Delivery Optimization Settings
FEATURES Optional Apps and Features Settings
OPTIONAL Optional Features Settings
PROGRAMS Uninstall or Change a Program
UPDATE Windows Update
UPDATEAH Windows Update Active Hours Settings
UPDATEH Windows Update History
UPDATEO Windows Update Advanced Option Settingss
UPDATER Windows Update Restart Options Settings
Linux
-----------------------------------------------------------------------------
BASH Run the Unix command specified on the command line
GEDIT gedit (graphical editor)
GIMP gimp (image manipulation)
GOOGLE-CHROME google-chrome (browser)
GOWINDOW GoWindow (God Mode)
LVLC Linux VLC (media player)
MICROSOFT-EDGE microsoft-edge (brower)
NAUTILUS nautilus (file browser)
WINCE Run the shell script that recompiles this program
XCALC xcalc (calculator)
XCLOCK xclock (visual clock)
XEYES xeyes (visual eyeballs)
XGC xgc (graphics demo)
XLOGO xlogo (visual X logo)
XMAN xman (man pages)
XMORE xmore (read-only text UI)
Locations
-----------------------------------------------------------------------------
ACCTPICT shell:AccountPictures
ADDNPROG shell:AddNewProgramsFolder
ADMTOOLS shell:Common Administrative Tools
ALLSTART Common Startup Folder
APPDATA shell:AppData
APPS Applications folder
BURN shell:CD Burning
CHNGPROG shell:ChangeRemoveProgramsFolder
COMMONPL Common Places
CONTACTS shell:Contacts
COOKIES shell:Cookies
CREDS shell:CredentialManager
CRYPKEYS shell:Cryptokeys
DESKTOP User desktop folder
DOCLIB shell:DocumentsLibrary
DOWNLOAD shell:Downloads
DPAPIKEY shell:DpAPIKeys
EXPSRCH shell:SearchHomeFolder
FAVS Favorites folder
FONTSDIR shell:Fonts
FREQ Frequently accessed folders
FSMGMT Shared Folders
GAMEXP shell:PublicGameTasks
HISTORY shell:History
HOMEGRP Home Group folder
IMPAPPSC shell:ImplicitAppShortcuts
INETCACH shell:cache
LIBS shell:Libraries
LINKS shell:Links
MAIL outlookmail:
MEDIASRV Media Servers
MSVIDEO microsoftvideo:
MYDOCS My Documents
MYVIDEO shell:My Video
PC This Computer
PICTLIB shell:PicturesLibrary
PLAYLIST shell:playlists
PORTDEV Portable Devices folder
PRINTHOOD shell:PrintHood
PRINTRSF shell:PrintersFolder
PROFILEF shell:Profile
PROGF C:\Program Files
PROGF86 C:\Program Files (x86)
PROGFC C:\Program Files\Common Files
PROGFC86 C:\Program Files (x86)\Common Files
PROGRAMF shell:Programs
PROGRAMSC Shared programs folder
PUBDESK Common desktop folder
PUBDOCS shell:Common Documents
PUBDOWN shell:CommonDownloads
PUBLIC shell:Public
PUBVIDEO shell:CommonVideo
QUICK shell:Quick Launch
RECENT shell:recent
RECYC Recycle bin folder
REMOVABL Removable Devices folder
RESOURCE shell:ResourceDir
RINGTONC shell:CommonRingtones
RINGTONE shell:Ringtones
ROAMTILE %USERPROFILE%\AppData\Local\Microsoft\Windows\RoamingTiles
SAVEGAME shell:SavedGames
SAVELOC Change where new content is saved
SEARCHES shell:Searches
SENDTO shell:sendto
STARTALL shell:Common Start Menu
STARTME shell:Start Menu
STARTUP User Startup Folder
SYS32 shell:System
SYS86 shell:Systemx86
TEMPLATES shell:templates
THISDEV This Device folder
UNUPDATE Installed Updates/Uninstall an Update
USERPINS shell:User Pinned
VIDLIB shell:VideosLibrary
WINDOWSF shell:Windows
Microsoft Office
-----------------------------------------------------------------------------
EXCEL Microsoft Excel
OA Microsoft Outlook Attach File <path>
OC Microsoft Outlook Compose
OD Microsoft OneDrive
OM Microsoft Outlook Compose To <email>
ONENOTE Microsoft OneNote
OUTLOOK Microsoft Outlook
PPT Microsoft PowerPoint
WORD Microsoft Word
Miscelaneous
-----------------------------------------------------------------------------
INSIDER Microsoft Windows Insider Program
QUICKASS Windows Quick Assist
SHOWD Show Windows desktop
TROUBLE Troubleshooting Windows
WINTAB Switch windows (Windows+Tab)
WUPDATE Update WSL
Networking
-----------------------------------------------------------------------------
ADDNETP Add Network Place
ADDPHONE Mobile Devices/Add Phone
BLUETOO Bluetooth settings
DIALUP Dialup Networking settings
ETHERNET Ethernet LAN Cable networking settings
FLUSHDNS Flush DNS Cache
HOTSPOT Mobile Hotspot Wi-Fi network settings
NETAVAIL Available networks
NETCON Network Connections folder
NETHOOD Network Shortcuts
NETSHARE Network and Sharing Center
NETSTAT Network status settings
PROXY Network Proxy settings
REMOTEAPP RemoteApp and Desktop Connections
VPN Virtual Private Network settings
WHEELSUP Airplane Mode settingse
WIFINETS Wi-Fi Network settings
WIFISETS Wi-Fi Network settings
YURPHONE Mobile Devices/Your Phone
Privacy
-----------------------------------------------------------------------------
MICCHECK Microphone privacy settings
PAPPDIAG App Diagnostics privacy settings
PAUTODWN Automatic File Downloads privacy settings
PBACKAPP Background Apps privacy settings
PCALLH Call History privacy settings
PCALLS Phone Calls privacy settings
PCALS Calendar privacy settings
PCAM ms-settings:privacy-webcam
PCONTACT ms-settings:privacy-contacts
PDEV Custom/Other Devices privacy settings
PDOC Documents privacy settings
PDOCS ms-settings:privacy-documents
PEMAIL Email privacy settings
PFEED ms-settings:privacy-feedback
PFS File system access privacy settings
PHIST ms-settings:privacy-activityhistory
PMSG Messaging privacy settings
PMYINFO Accoung Information privacy settings
PNAGS Notifications privacy settings
PPICS ms-settings:privacy-pictures
PRADIOS ms-settings:privacy-radios
PRIVACY Privacy settings control panel
PSPEECH ms-settings:privacy-speech
PTASKS ms-settings:privacy-tasks
PTYPE ms-settings:privacy-speechtyping
PVOICEA ms-settings:privacy-voiceactivation
SRCHPRM Permissions and History
STALKME Location privacy settings
Screen Savers
-----------------------------------------------------------------------------
3DTSS 3D Text Screen Saver
3DTSSS 3D Text Screen Saver settings
3DTSSW 3D Text Screen Saver window
BLANK Blank Screen Saver
BUBBLES Bubbles Screen Saver
BUBBLESS Bubbles Screen Saver settings
BUBBLESW Bubbles Screen Saver window
DEFAULTSS Default Screen Saver
MYSTIFY Mystify Screen Saver
MYSTIFYW Mystify Screen Saver window
PHOTOSS Photos Screen Saver
PHOTOSSS Photos Screen Saver settings
PHOTOSSW Photos Screen Saver window
RIBBONS Ribbons Screen Saver
RIBBONSS Ribbons Screen Saver settings
RIBBONSW Ribbons Screen Saver window
SSS Screen Saver Settings
Security
-----------------------------------------------------------------------------
ADVSEC Advanced firewall security settings
AUTHMAN Security Authorization Manager
BITLOCK Bitlocker Drive Encryption
CERTLM Security Certificate Manager - Local Machine
CERTMGR Security Certificate Manager - Current User
CREDWIZ Stored Usernames and Passwords
EUP Edit User Profiles
FACESIGN Face recognition security settings
FINGSIGN Fingerprint recognition security settings
FIREWALL Firewall security settings
GPEDIT Local Group Policy Editor
KEYSIGN Security key (USB) security settings
LUSRMGR Local Users and Groups
PSR Steps Recorder
REKEYWIZ Encrypt Filesystem with Certificate
SECCNTR Windows Security Center/Security at a Glance
SECMAN Security and Maintenance control panel
SECPOL Security Policy
SIGNIN Security sign-in settings
SYSCERTS System Security Certificates
UAC UserAccountControlSettings.exe
UPSIGN Security dynamic lock settings
USER User Accounts
USERACTS Security User Accounts
USERPASS control.exe
USERS User Profiles
WINSEC Windows Security Settings
Settings
-----------------------------------------------------------------------------
ABOUT About settings
ACTIVATE Activate Windows
ACTIVATN Windows activation settings
AUTOPLAY Autoplay Settings (defaults)
AUTOPLYD Autoplay Settings by Device type
BACKGROUND Desktop background settings
BACKUP Backup settings
BATTERY Battery settings
CAPTURES Screen capture settings
CLP Clipboard settings
COLORS Windows Colors settings
CONDEV Connected devices (bluetooth and other devices) settings
CONTROL Control Panel (small icons)
CPCATS Control Panel (categories)
CROSSDEV Shared experiences accross devices settings
DATAUSE Data usage settings
DATETIME Date and time settings
DEFAULT Choose default applications settings
DEV Developer settings
DEVDISC Connectable device discovery settings
DEVICES Devices and Printers
DEVMAN Device Manager control pane
DISPLAY Display settings
FILEHIST File History
FILEOPT File Explorer settings
FINDMYDV Find my device settings
FOCUS Quiet hours/focus assist settungs
FONTVIEW Font Viewer
GAMEBAR Game bar settings
GAMEMODE Game mode settings
GRAPHICS Advanced graphics settings
INET Internet control panel
INTL Region
ISCSICPL iSCSI
JOY Game Controllers control panel
KEYBOARD Keyboard settings
LANGUAGE Regional language settings
LOC Location Information control panel
LOCK Lock screen settings
MAPS Map settings
MORFONTS More Font settings
MOUSE Mouse control panel
MOUSESET Mouse settings
MULTITSK Multitasking settings
NAGS Notification settings
NIGHT Night light settings
OFFLMAPS Offline map settings
OLDFONTS Legacy fonts control panel
OTHERUSR Other users settings
PEN Pen input settings
PERFOPT Performance Options
PERSONAL Personalization settings
POWER Power control panel
POWS Power and Sleep settings
PRNTSCAN Printer and Scanner settings
PROJECT Project (dark gray sidebar at right of screen)
PROJECTME Projecting to this PC
RDSET ms-settings:remotedesktop
RECOVER Recovery settings
REGION Regional formatting settings
SCALING ms-settings:display-advanced
SETEMAIL Email and Accounts settings
SETSPCH ms-settings:speech
SETSTART ms-settings:startupapps
SETTINGS Settings control panel
SETVIDEO ms-settings:videoplayback
SIGVERIF File Signature Verification
SOUND Sound control panel
SOUNDDEV ms-settings:sound-devices
SOUNDS Sound settings
SPEECH Configure your speech recognition experience
SRCHSETS Windows Search (Cortana) Settings
START Start Menu personalization settings
STARTFOL Personalize/choose which folders appear on the start menu
STORPOL Storage Policies
STORSENS Storage Sense
STORSP Manage Storage Spaces
SYNCSET Sync Settings...settings
SYSPROP Sound Properties control panel
TABLET Tablet Mode settings
TASKBAR Taskbar settings
THEMES Windows Themes settings
TIMEDATE Date and Time control panel
TOUCHPAD Touchpad settings
TYPING Typing settings
USB USB settings
UTILMAN Utility Manager (display)
VOL Volume settings
WEBAPPS ms-settings:appsforwebsites
WORKPLC Workplace or school settings
YOURINFO Your Information
Shutdown
-----------------------------------------------------------------------------
BOOT Reboot
BOOTOPT Reboot to boot options
DOWN Shut down
FIRMWARE Reboot to firmware
HYB Hybernate
LOGOFF Log off
SHUTUI Shutdown UI
Sysinternals.com
-----------------------------------------------------------------------------
AUTORUNS Identify and control startup processes
BGINFO Set desktop background to system information
DISKVIEW Disk space usage visualizer
DU Disk usage
HANDLE List open file handles
LISTDLLS List processes and their DLLs
PROCEXP Process Explorer
PROCMON Process Monitor
PSKILL Process killer
PSLIST Process lister
ZOOMIT crash it, change it, mail β upgrade it, Charge it, point it, zoom it, press it, Snap it, work it, quick β erase it...Technologic
Utilities
-----------------------------------------------------------------------------
ALARMS Alarmns & Clock
BACKUP7 Windows 7 backup
BINGMAPS Bing Maps
BINGNEWS Bing News
CAL Calendar
CALC Calculator
CAM Camera
CDINFO Crystal Disk Info
CHARMAP Character Map
CHKDSK Check hard disk for errors and issues
CLEANMGR Disk Cleanup
CLICONFG SQL Server Client Network Utility
CLOCK Clock
CMD cmd.exe (see above)
COLORCPL Color Management
COMPMGMT Computer Management
COMSERV Component Services Configuration
CTTUNE Clear Type Text Tuner
DEVMODE DevModeRunAsUserConfig.msc
DFRGUI Optimize Hard Drives
DIALER Phone Dialer
DISKMAN Disk Management
DISKPART Disk partitioner
DPAPIMIG Protected Content Migration
DVDPLAY DVD player (Windows Media Player)
DXDIAG DirectX Diagnostics Tool
EDITENV Edit environment variables
ENV Show Windows environment
EUDCEDIT Private Character Editor
EVENTVWR Windows Event Viewer
EXP explorer.exe (see above)
FAM Ask for permission (family)
FAXSCAN Windows Fax and Scan
FSQUIRT Bluetooth File Transfer
FXSCOVER Fax Cover Page Editor
GROOVE Microsoft Groove Music
HDWWIZ Add Hardware Wizard
IEXPLORE Internet Explorer
IEXPRESS Create a Self-Extracting Executable
ISOBURN ISO disk burner
KIOSK Set up a Kiosk
LPKSETUP Language Pack Setup
MAGNIFY Screen magnifier
MDSCHED Windows Memory Diagnostics
MMC Microsoft Management Console
MOBILITY Windows Mobility Center
MOVIES Microsoft Windows Video (Movies and TV)
MP Windows Media Player
MRT Malicious Software Removal Tool
MSACT Windows Action Center (right dark gray sidebar)
MSCONFIG Microsoft Configuration tool
MSDT Microsoft Support Diagnostics Tool
MSINFO32 System Information
NOTEPAD Windows Notepad
ODBCCONF odbcconf.exe
OSK On-screen keyboard
PAINT Windows Paint
PAINT3D Paint3D
PEOPLE People
PERFMON Performance Monitor
PHOTOS Photos and Video Editor
PRESSET Presentation Settings
PRINTMAN Print Management
PRINTMIG Printer Migration
PRINTUI Print User Interface
PSISE PowerShell Integrated Scripting Environment (ISE)
PWRD keymgr.dll,PRShowSaveWizardExW
RASPHONE Remove Access Phonebook
RD Remote Desktop Client
RECDISC Create a system repair disk
REGEDT32 Windows Registry Editor
REMOTEAS Windows Remote Assistance
RESMON Windows Resource Monitor
RESTORE Restore system files and settings
RSOP Resultant Set of Policy
RUN Windows Run Dialog
SCAN Scan
SCLIP Screen capture (Windows+Shift+S)
SERVICES Windows Services
SHRPUBW Create Shared Folder Wiard
SNDVOL Sound and Volume
SNIPTOOL SnippingTool
SOL Solitare
SOUNDREC Sound Recorder
SSKETCH Snip and sketch
STIKYNOT Sticky Notes
STORE Microsoft store
SUPPORT Microsoft support
SYNC Sync Center
TABCAL Digitizer Calibration Tool
TASKMGR Windows Task Manager
TASKSCHD Windows Task Scheduler
TIPS Windows tips / getting started
TPM Trusted Platform Module
TPM.MSC Trusted Platform Module Management on Local Computer
VERIFIER Driver Verifier Manager
WINTOOLS Windows Tools
WINVER Windows Version
WMIMGMT WMI Management
WORDPAD Windows Wordpad
WUSA Windows Update Standalone Installer
wink : 459 known command codes
wink : access Windows features : Help requested by -help
wink [opts] <CODE> [arguments]
-d dry (do not execute)
-e export (configuraiton JSON)
-p pretty-print (for use with -e)
-v verbose (print command line)
wink HELP : display command usage information
wink HELP | grep -i "text" # identify command code matching text
This blog post is the seventh in a series that describes the structure of the wink command line program that I have written in rust and that I use to invoke other Windows and Linux programs from bash and Windows shells under Windows Subsystem for Linux. This post describes several types used by the wink program to contain metadata about commands that Windows can invoke and to invoke such commands. This blog post describes several files that appear as the crate::wsl::inv path and its child paths such as crate::wsl::inv::invocable.
An Invocable represents metadata about a command that Windows can invoke as an executable, with cmd.exe, with explorer.exe, or with WSL bash.exe, where cmd.exe supports child commands such as call and start, neither of which seems to work reliability as intended, such as to start a Windows binary as a background process.
Invocables can be serialized to and deserialized from JSON, and support some cloning and debugging features.
The implementation includes the cmp(), partial(), and eq() functions required for sorting Invocables by their command codes.
The base() function returns an Invocable with default values applied. The bin_with(), bin(), exp_with(), exp(), bkg_with(), bkg(), cmd_with(), cmd(), sh_with(), and sh() functions create Invokers with different properties to invoke commands in various ways allowed by Windows, which may use (named _with) or not use command line parameters.
The get() function constructs the default CategoryList by creating a number of InvocableCategories with hard-coded names and calling corresponding methods before adding them to this InvocableCategoryList. I intend to refactor this to use delegates. This includes some logic to add additional InvocableCategories and Invocables from a JSON file to this InvocableCategoryList, which likely needs some corrections to resolve potential conflicts in category and command code names.
The get_invocable function uses some rust constructs to avoid nested for loops. For each category, in its list of Invocables, find the Invocable with the command_code value that matches the command_code argument. The pipes indicate delegates.
if std::path::Path::new(&path).exists() {
// if the path exists, then propagate all errors, so OK to unwrap from here
let data = std::fs::read_to_string(&path)
.unwrap_or_else(|_| panic!("Unable to read {0}", &path));
let deserialized: InvocableCategoryList = serde_json::from_str(&data).unwrap();
If the file at the specified path exists, then panic if it cannot be read; otherwise, create an InvocableCategoryList from its contents. Underscore is a construct that is something like a default everything.
This is struct has no fields but defines the invoke() function that uses an Invocable and some parameters from the command line to invoke a process using std::process::Command. The code seems relatively self-explanatory.
/src/wsl/inv.rs: Groups the types defined in the files under the /src/wsl/inv directory under the wsl::inv path.
pub mod invocable;
pub mod invocablecategory;
pub mod invocablecategorylist;
pub mod invoker;
If I understand correctly, this makes the child paths available in this parent path, basically causing the compiler to include those files or allow other files to reference the types that they contain through the wsl::inv path.
This blog post is the sixth in a series that describes the structure of the wink command line program that I have written in rust and that I use to invoke other Windows and Linux programs from bash and Windows shells under Windows Subsystem for Linux. This post describes a library named wsl that the wink program defines for features specific to Windows Subsystem for Linux, defined by the /src/wsl.rs file and hence the crate::wsl path.
/src/wsl.rs: Library specific to Windows Subsystem for Linux.
Because this logic is not specific to the wink program, it could appear in a separate crate or even a separate project.
The wsl_path_or_self() method accepts a string slice and a Boolean indicating whether to convert that slice to Unix or Windows, and returns the value as a String. It uses a std::Process::Command to invoke the wslpath command (not available from cmd.exe, although cmd.exe can call bash.exe which can call wslpath) with arguments that control its output. If any error occurs, then it this function returns the value passed to it, as it was unable to convert that path.
The is_windows_or_wsl() function is true if is_windows() or is_wsl() returns true. The is_windows() function returns true if the wink command is running directly under windows rather than under WSL within Windows. The is_wsl() function returns true if the wink command is running under WSL, typically in a bash shell. The get_user_home() function returns the value of the USERPROFILE environment variable under Windows or the HOME environment variable under WSL. The get_user_home_default() function calls get_user_home() and returns its value or an empty string if the environment variable was not defined. The get_config_file_path() function uses get_user_home_default to construct a path to a configuration file that the wink command may use.
The /src/wsl.rs file also contains a tests module.
mod tests {
#[test]
fn get_user_home_default() {
println!("wsl::tests::get_user_home_default()");
//TODO:
}
#[test]
fn it_converts_c_drive() {
assert_eq!(
&crate::wsl::wsl_path_or_self("C:\\", true /*unix*/),
"/mnt/c/"
);
// assert_eq!(&crate::wsl::wsl_path_or_self("C:", true /*unix*/), "/mnt/c"); wslpath unexpectedly returns C:
}
#[test]
fn is_windows_or_wsl() {
println!("wsl::tests::is_windows_or_wsl()");
assert_eq!(
super::is_windows_or_wsl(),
true,
"Run the tests against the Linux binary under WSL."
);
}
#[test]
fn is_windows() {
println!("wsl::tests::is_windows()");
assert_eq!(
super::is_windows(),
false,
"Run the tests against the Linux binary under WSL."
);
}
#[test]
fn is_wsl() {
println!("wsl::tests::is_wsl()");
assert_eq!(
super::is_wsl(),
true,
"Run the tests against the Linux binary under WSL."
);
}
}
This blog post is the fifth in a series that describes the structure of the wink command line program that I have written in rust and that I use to invoke other Windows and Linux programs from bash and Windows shells under Windows Subsystem for Linux. This post describes the WinkConfig struct used to represent command line arguments to the program, defined in the /src/winkconfig.rs file and hence crate::winkconfig:WinkConfig.
/src/winkconfig.rs: Defines and implements the WinkConfig struct used to model command line arguments to the wink program.
The file /src/winkconfig.rs defines the WinkConfig struct and the implementation of its members (crate::winkconfig::WinkConfig). WinkConfig represents command line parameters passed to the wink command.
Before the definition of the WinkConfig struct, this line enables the serde library to serialize the fields in the struct as JSON. Compilations will fail if the struct does not meet requirements for serde. For my purposes, all fields are public.
#[derive(serde::Serialize)]
The fmt() function renders the WinkConfig as JSON for debugging purposes, repurposing the -p parameter used by the wink command itself to enable pretty-printing of JSON exports of its configuration.
Most of the logic is in the new() function, which accepts a vector (ordered list) of strings that the main() method in /src/main.rs determines from command line arguments and passes to new().
The first command line argument is the name of the command, such as wink or wink.exe or /path/to/wink. The new() function ignores that at first, iterating the command line arguments until it finds βhelpβ or one that does not begin with a slash or a dash, which should be the command code that indicates which invocable to invoke. Any other command line options enable options or render help.
Note the use of to_owned. Rust enforces scope in a way that sometimes requires use of constructs to control which variables determine when the system frees memory.
The new() method then constructs a WinkConfig. Note that when field names match variable names, we can specify field names without the matching variable names.
If there is no reason to render usage information, then the new() method returns the WinkConfig in an Ok enumeration. Otherwise, it returns the WinkConfig and Box that contains a HelpError (/src/helperror.rs) that informs the caller to render usage information for the command.
To demonstrate testing, this class includes a mod named tests, which is a naming convention. When run with cargo run, a special main() method invokes tests attributed such as these.
The it_get_from_command_line_args() function removes some command line arguments that may appear when running under cargo test.
The it_has_a_path() test panics, which means crashing the program, but the #[should_panic] attribute interprets only a panic as a successful test. This is useful for determining absolute paths to things β run the tests for the thing and see its path.