transfer::data::source(n)
β¨ transfer::data::source(n) β¨
okay so bestie, welcome to transfer::data::source β it lives in the Data transfer facilities corner of the tcllib universe, and today we're gonna make it make sense π
πΈ NAME πΈ
transfer::data::source β Data source (yes queen, that's literally the whole job description)
β¨ SYNOPSIS β¨
package require Tcl 8.5 9
package require snit ?1.0?
package require transfer::copy ?0.3?
package require transfer::data::source ?0.3?
transfer::data::source objectName ?options...?
objectName method ?arg arg ...?
objectName destroy
objectName type
objectName data
objectName size
objectName valid msgvar
objectName transmit channel blocksize done
π DESCRIPTION π
So this package hands you objects that mostly just... describe where some data is coming from before you yeet it somewhere π¦. They're the origin story of a transfer, fr fr.
And they're not just decorative β they can also initiate the actual transfer of the information they're describing onto a channel, using the foundation package transfer::copy. Slay π
π API π
π PACKAGE COMMANDS π
transfer::data::sourceobjectName ? options... ? β this command creates a brand-new data source object, and that object gets its very own Tcl command, whose name is objectName. That object command is explained in full detail down in the Object command and Object methods sections, and the options it supports are all in the Options section. Also: if objectName isn't fully qualified, the object command gets created under the current namespace; if it is fully qualified, it lands in whatever namespace you specified. Either way, the fully qualified name of the object command is returned as the result. periodt π
π¦ OBJECT COMMAND π¦
Every object made by the ::transfer::data::source command has this same general form:
objectNamemethod ? arg arg ... ? β the method and its arguments decide exactly what the command does. Full specs live in the Object methods section, bestie π
π OBJECT METHODS π
objectName destroyβ this method destroys the object. And ngl, doing that while a transfer started by the object is still active is totally safe β β because all the data the transfer itself needs was already copied, and when the transfer finishes it will not try to touch the initiating object ever again. iykyk: the transfer is completely separate from the source object itself. main character energy π«ΆobjectName typeβ this method returns a string describing the type of data the object is referring to. The possible values and what they mean:undefinedβ no data was specified at all, or it was specified incompletely. Basically the object has no idea what type it is πstringβ the data to transfer is contained in a string.channelβ the data to transfer is contained in a channel.
objectName dataβ this method returns a value depending on the type of data the object refers to, and that's your way in to actually access the data. Heads up though: it throws an error if the type isundefinedπ. For typestringthe returned result is the data itself; for typechannelthe returned result is the handle of the channel holding the data.objectName sizeβ this method returns a value depending on the type of data the object refers to: the size of the data. It also throws an error if the type isundefined. And ooh, important: returning a negative value signals that the object simply can't figure out an absolute size upfront β like, say, for data sitting in a channel πobjectName validmsgvar β this method checks whether the object's configuration is valid. It returns a boolean flag: True if the object is valid, False otherwise. In that False case, the variable whose name is stored in msgvar gets set to an error message describing the problem it found with the configuration. Otherwise, that variable is not touched. not me being thorough β¨objectName transmitchannel blocksize done β this method kicks off a transfer of the referenced data to the specified channel π. When the transfer completes, the command prefix done is invoked, following the rules for the option-commandof the commandtransfer::copy::doin the packagetransfer::copy. The blocksize says how big the chunks are that get transferred in one go β see the option-blocksizeof the commandtransfer::copy::doin the packagetransfer::copy. go off π
β OPTIONS β
All data sources support the options listed below π. Now listen closely, because there's a little twist: the first four options are semi-exclusive β each one specifies a different type of data source plus its associated content. And if you specify more than one of them, then the last option specified is the one that actually configures the object. no take-backsies π
-stringtext β says the source of the data is an immediate string, and its associated argument contains the string in question.-channelhandle β says the source of the data is a channel, and its associated argument is the handle of the channel containing the data.-filepath β says the source of the data is a file, and its associated argument is the path of the file containing the data.-variablevarname β says the source of the data is a string stored in a variable, and its associated argument contains the name of the variable in question. That variable is assumed to be global or namespaced, anchored at the global namespace.-sizeint β this one specifies the size of the data transfer. It's optional and defaults to-1. And just so you know: this value, and any other value less than zero, signals to transfer all the data from the source π¦-progresscommand β if you specify this, it defines a command to be invoked for each chunk of bytes transmitted, letting you monitor how the transmission is going π. The callback is always invoked with one additional argument: the number of bytes transmitted so far. obsessed π
π BUGS, IDEAS, FEEDBACK π
This document, and the package it describes, will undoubtedly contain bugs and other problems π. Please report such in the category transfer of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. Please also report any ideas for enhancements you may have for either the package and/or the documentation π.
When proposing code changes, please provide unified diffs, i.e. the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. slay π
π₯ KEYWORDS π₯
channel, copy, data source, transfer
πΈ CATEGORY πΈ
Transfer module
π COPYRIGHT π
Copyright (c) 2006-2009 Andreas Kupries <andreas_kupries@users.sourceforge.net>
and that's the whole page bestie π«Ά it's from tcllib, it's version0.3, and the page itself istransfer::data::source(n). mwah πβ¨
π¦ where this page comes from
- fedora 43: tcllib 2.0-3.fc43 Β· TCL
- fedora 44: tcllib 2.0-4.fc44 Β· TCL
- nixos 26.05: tcllib 2.0
- nixpkgs unstable: tcllib 2.0
- Copyright (c) 2006-2009 Andreas Kupries <andreas_kupries@users\&.sourceforge\&.net>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms